Reproducing:
1. Enable opensearch
2. Install a module like block404 or simply configure a custom 404 page in the error reporting menu
3. Visit any page that should cause a 404
Expected:
Normal page load
Result:
Fatal error
I've looked into it a bit and it is caused because you are running token_replace_multiple inside hook_init. This triggers the global 'current-page-title' token. The problem is arises because triggering this token caches the current menu trail, so when the 404 page attempts to render a different page, it crashes.
I'm not sure what the best solution, but looking through the code, I was wondering why you have all of these settings inside hook_init. Wouldn't it be better to have all of this inside of a preprocess_page, since you assigning feeds?
Comments
Comment #1
13rac1 CreditAttribution: 13rac1 commentedChanging to critical, since this causes fatal errors site wide when custom 404 and 403 pages are specified. Many sites and modules rely on these features including 404 Blocks, Logintoboggan, and Private Downloads.
The specific error is:
The fatal error occurs in the l() function when the $options value is passed as NULL. The value is NULL because the active menu trail is incorrect. This is the active trail for Private Downloads:
$active_trail[1]['localized_options'] is not set, because menu_set_active_trail() is called in init() and caches the data before the Drupal access denied redirection runs. This is the backtrace for the early run of menu_set_active_trail(), ignore the page_title module:
A potential fix is to modify Open Search to not call token_replace_multiple() during init().
Comment #2
kmontysub
Comment #3
c960657 CreditAttribution: c960657 commentedHere is the issue for Drupal core: #918356: WSOD when drupal_get_title called during hook_init and custom 403 or 404 pages are being used
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI changed the code for
hook_init()
, which now checks the headers set by Drupal, and verifies if Drupal is returning an error 403 (or error 404) page; it also verifies if the site is off-line, and the user doesn't have the permission to administer the site configuration. In these cases, the function exits without doing anything.I committed the code, and created a new release (version 6.x-1.4-beta1).
Comment #6
szy CreditAttribution: szy commentedIt still happens.
Custom Error 6.x-1.x-dev
Search 404 6.x-1.9
Search config 6.x-1.6
OpenSearch feed 6.x-1.4-beta1
*edit*
Now it's fine: 'Allow PHP code to be executed for 404' must be off.
Szy.