I encountered a bug caused by menu_get_active_breadcrumb in D6.
This is what I found (after digging in the code):
- menu_get_active_breadcrumb calls menu_get_active_trail
- some items don't have access, and so _menu_item_localize is not called, resulting in the item having no ['localized_options']
- the l() function is called with NULL for its $options argument, resulting in an error.
I don't even have breadcrumbs activated on my site, but it is called nevertheless.
Relevant stack trace / tree:
drupal_access_denied
theme
call_user_func_array
template_preprocess_page
drupal_get_breadcrumb
menu_get_active_breadcrumb
. menu_get_active_trail
. menu_set_active_trail
. menu_get_item
. _menu_translate
. // _menu_item_localize not called, because item has no ['access']
. // effect: no ['localized_options']
. // $active_trail contains items without ['localized_options']
. l
. // error, because $options is not an array
This bug seems to show up very rarely (didn't find any other issues).
However, I think it is a typical example of non-robust code, which does not check if variables what they are supposed to be.
So, even if you can't reproduce the error, would be good to have a look into the code and see if some sanity checks should be added here and there.
Some info that could help:
- I use the 'me' aliases module. I didn't get the error without this module (or maybe I just didn't check).
- I run PHP 5.3 (with a few patches to get around the errors)
- The path was user/1 (but user/2 will do as well)
I will update this issue when I have more info.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | localized_options_menu-588158-6.patch | 755 bytes | ttkaminski |
| #6 | localized_options_menu.patch | 654 bytes | ttkaminski |
Comments
Comment #1
donquixote commentedI should clarify my stack trace diagram.
----------
Furthermore, I found that the problem can be fixed by changing the 403 (access denied) page. I had this page set to "user", with the intention to show a login box (which does work on some other pages). I changed it to user/login, now it works.
I'm not sure if this is a sufficient solution, or if it needs further investigation.
Comment #2
sbozhko commentedHave the same issue with custom 403 page.
After some investigation, here is what i've found:
Function _menu_translate calls _menu_item_localize which adds "localized_options" element to array only if user has access to this menu item.
In my case, user don't have access to it (as i am trying to display 403 page). Therefore this element is NULL, and l() throws an error.
Comment #3
sbozhko commentedComment #4
Anonymous (not verified) commentedI had this issue once in combination with Search404 and Page Title module.
The problem was, that the menu_get_active_breadcrumb() eventually called an l() function with an nulled $options. Leading to a crash in common.inc, because $options (localized_options) must be an array.
The $options was set and empty, but was not an array. So common.inc crashed in the l() function called by a menu_get_breadcrumb.
Indeed somewhere a check for $options is missing. It should also check if $options is really an array or an empty string.
Comment #5
pepe84 commentedI fix a similar bug redirecting to "Not found" page using hook_menu_alter:
Comment #6
ttkaminski commentedPlease see #899508-19: l() function - Unsupported operand types in common.inc for a description of the problem. It turns out to be, in my option, a bug in drupal due to an optimization within drupal core. I posted a patch, attached here again for convenience. Hopefully the patch will not break anything so please review and hopefully we can get it into the core.
Comment #8
ttkaminski commentedResubmitted after generating patch using git diff against drupal 6.22
Comment #9
David_Rothstein commentedNot sure, but I think this may be the same issue as #918356: WSOD when drupal_get_title called during hook_init and custom 403 or 404 pages are being used and therefore fixed by the patch there (at least for D7 and D8)?
Looking at the patch here, I don't think it makes sense to pretend that a menu item is localized when it's not... If it hasn't been localized, then the title hasn't been translated/etc, so it doesn't make any sense to try to generate a link to it. I think we need a fix that comes closer to addressing the root cause and avoids trying to generate such a link in the first place.
Comment #10
kenorb commentedI've the same fatal error at /users/admin.
I'm using me module as well.
The patch fix the problem.
Comment #11
kenorb commentedComment #12
David_Rothstein commentedNeeds work and further investigation, per #9.
Comment #13
q2_faith commented#10 works for me(D7)