Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When running devel under drush dpm(), dvm() etc fail to function. This means that 2 debug systems need to be implemented when trying to debug problems through drush and the browser.
Comment | File | Size | Author |
---|---|---|---|
#13 | 1159158-13.patch | 4.93 KB | areke |
#11 | devel-1159158-make-d-m-functions-work-under-drush-11.patch | 5.83 KB | skwashd |
#1 | devel-1159158-make-d-m-functions-work-under-drush.patch | 3.19 KB | skwashd |
Comments
Comment #1
skwashd CreditAttribution: skwashd commentedThe attached patch checks to see if the script is running under drush and if so messages are routed to devel_set_message() which properly handles user feedback depending on which environment it using.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedLooks pretty handy to me. I'll wait a bit for feedback before committing
Comment #3
Dave ReidShould we use drupal_is_cli() rather than a custom devel_is_drush()?
Comment #4
skwashd CreditAttribution: skwashd commented@DaveReid, If cron.php is called via the PHP cli it will break as drupal_is_cli() will return TRUE, but it won't be running via drush. I use a custom devel_is_drush() style functions in my in house custom modules which which have drush specific behaviour.
Another problem is that drupal_is_cli() is only available for D7+
If there is a more reliable way of detecting drush, then I'm happy to change the function.
Comment #5
Dave Reiddevel_set_message() will still handle message if drush isn't being used though right? And cron should be running as anonymous so messges are destroyed anyway.
Comment #6
msonnabaum CreditAttribution: msonnabaum commentedYeah, I'd rather not depend on drupal_is_cli() since this would be nice to have in d6. Although devel_set_message isn't in the 6 branch of devel anyhow, so that would need to be backported.
Comment #7
skwashd CreditAttribution: skwashd commented@DaveReid Good points. Sounds like I just signed up for adding drupal_is_cli() support in drush for D6 (is 5 still supported?). If there is no objections to that approach when I wake up in the morning I'll try to find time to work on a patch for that.
Marking as postponed.
Comment #8
Dave ReidSo the solution is we add a devel_is_cli() in d6 and use that instead just like backporting devel_set_message()? Not sure which approach would be better.
Comment #9
skwashd CreditAttribution: skwashd commentedI'm tired.
Here is my proposed battle plan:
* I fix the D8 version to use drupal_is_cli(), D7 can just cherry pick.
* The D6 version of the patch backports devel_set_message() and drupal_is_cli() as devel_is_cli()
DaveReid is correct that drupal_is_cli() would need to go into D6 core, not drush.
I'll probably be back onto this in ~10hrs, unless there are objections.
Comment #10
msonnabaum CreditAttribution: msonnabaum commentedI see a couple problems with this approach. devel_set_message() is calling drush_log($msg, NULL), which doesn't print out without the debug flag. Without the second arg to drush_log, it still only prints if you pass verbose to drush.
I'd like to propose a considerably simpler approach:
This avoids the issues discussed previously and it doesn't print html encoded characters on the cli.
Comment #11
skwashd CreditAttribution: skwashd commentedAttached is the D8/7 version as outlined in comment #9.
I'm not opposed to implementing @msonnabaum's suggestion, but I that part of the problem is how devel_set_message() calls drush_log. I think that fixing how devel_set_message() calls drush_log() is out scope for this issue.
Comment #12
pcambraTagging
Comment #13
areke CreditAttribution: areke commentedThis patch needed a reroll, so I rerolled it.
Comment #14
MustangGB CreditAttribution: MustangGB commentedIf no-one else has any comments then in terms of functionality this works as expected.
Comment #15
MustangGB CreditAttribution: MustangGB commentedOops, this actually needs re-rolling against the latest release.
Comment #16
moshe weitzman CreditAttribution: moshe weitzman commentedThis looks wrong to me. Drush requests happen in the context of a user when -u is provided. Folks can pass in a user and then they will pass a user_access() test.
Comment #17
moshe weitzman CreditAttribution: moshe weitzman commentedComment #18
moshe weitzman CreditAttribution: moshe weitzman commentedComment #19
moshe weitzman CreditAttribution: moshe weitzman commentedNot positive, but I think our move to Kint will fix this. dsm() and such now use Kint of that submodule is enabled so you can try for yourself and reopen if needed.