I found this problem when attempting to split some code from the store module in Ubercart out into an include file:

  1. The code in the include file is necessary for loading an order.
  2. Some URLs use the menu system's autoloading feature to load orders.
  3. I must include the include file in hook_init() before the order is loaded.
  4. However, before I can, globalredirect_init() forces a load of the menu item.
  5. Because my include file isn't loaded yet, I get a WSOD and a PHP error about the missing essential class.

I can explain it in more detail if need be, but the gist of it is Global Redirect is causing an error that Drupal's bootstraps takes pains to avoid... namely, its implementation of hook_init() is calling functions that aren't supposed to be executed until every module's had a chance to use hook_init(). I could tweak the module weight, sure, but that's not failproof or future proof.

I believe it would benefit this module to review the functions it's calling in hook_init() and see if there is a possible workaround. You'll notice that Drupal core doesn't even try to use the function menu_get_item() (the problem child here) until after the full bootstrap is complete.

Also, since hook_init() isn't invoked on cached pages, I wonder what that means for cached versions of duplicate content on a site. But I digress...

Comments

nicholasThompson’s picture

Status: Active » Fixed

In 6.x-1.x-dev, this feature is now an option which is disabled by default.... Although I just did a quick test by adding an alias to 'admin' of 'foobar'. With the GR menu check enabled or disabled, it appear Drupal denied access to anonymous before GR got a chance to do anything. This might actually be an unnecessary feature... Needs further investigation.

rszrama’s picture

Yeah, sorry, re-reading this it looks like I may not have drawn enough attention to the fact that this is related to autoloading objects in a URL as signified by wildcards in the menu item path. However, it does so after every module's hook_init() has been run, allowing functions necessary for the autoload process to sit in include files.

For example, the URL /admin/store/orders/32 matches to /admin/store/orders/%uc_order. The menu system will autoload order 32 and let me pass that to a callback as an argument. The code here was interfering with that.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.