hook_init() breaks drush
fuerst - October 28, 2009 - 10:43
| Project: | Path redirect |
| Version: | 6.x-1.0-beta4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
As described in #594326: Breaks Drush for the module Global Redirect a redirection breaks the execution of the drush shell command. The fix it to return from path_redirect_init() without calling _path_redirect_check() when executing path_redirect_init() through drush.

#1
The attached patch simply is adapting the patch from #594326: Breaks Drush to this module.
#2
Why would a redirect be executed by Path redirect? I can understand Global redirect since it 'works' for basically all requests, but path redirect should only happen on specific paths. Did you actually test that this doesn't work with Drush? Can you give insight into the conditions leading to failure?
#3
When executing
drush updateat the command line the$robject inside_path_redirect_check()will be populated by this values:stdClass Object(
[rid] => 24
[path] => home/home
[redirect] => node/5
[query] =>
[fragment] =>
[language] =>
[type] => 301
[last_used] => 1256747530
)
The
$_GETvariable has this content:Array(
[q] => home/home
)
At my site there exists a path redirect for home/home which is configured as front page in /admin/settings/site-information. If I delete that redirection or set the front page configuration to another non-redirected URL like node/5 the error does not occur.
Looks like drush always calls the front page of Drupal. If the front page is set to a path redirect a redirection will be triggered which in turn breaks Drush.
So the solution to not redirect when called by Drush looks good to me. What do you think?
#4
In this case, you should be using global redirect and not using path_redirect.
#5
Path Redirect will be used by the Pathauto module. So the redirect in question is not configured by me but setup automatically by Pathauto. Looks like a unfortunate condition which is surely not the fault of Path Redirect. May be it can be fixed in Drush itself. Will get back to the issue queue there.