I mark this as major because it's a weird and hard-to-debug problem. It gave me an headache to figure out what happened.
Description of the bug: when the cache is flushed, you sometimes end up with a broken or disappeared management menu. This especially happens when I save a view. The management menu, which for me is displayed by the Admin Menu module, only has one link: "Add content".
Cause: an access callback from the Admin module, admin_landing_page_access()
, stores in cache the access info, so that it's only calculated once by path and page load. But in the bootstrap phase, XML Sitemap Menu module makes a temporary user switch to anonymous account and calls menu_link_load()
, which calls _menu_link_translate()
, _menu_check_access()
and finally admin_landing_page_access()
. So the access info is calculated with the anonymous account, which has access to very few (or none) admin links. Thus the links do not appear.
Fix proposal:
1. Use drupal_static() system so that admin_landing_page_access()
's cache can be flushed by other modules.
2. Use drupal_static_reset() in XML Site Map Menu after the user switch has been reverted.
I open a related issue for Admin.
Comment | File | Size | Author |
---|---|---|---|
#9 | 2306823-static-reset-on-user-switch.patch | 1.02 KB | Dave Reid |
#8 | 2306823-static-reset-on-user-switch.patch | 844 bytes | Dave Reid |
#6 | 2306823-static-reset-on-user-switch.patch | 844 bytes | Dave Reid |
#1 | admin_compatibility-2306823-1.patch | 524 bytes | GaëlG |
Comments
Comment #1
GaëlGComment #2
Dave ReidShould we prevent future issues by just doing just drupal_static_reset() on all of the statics?
Comment #3
GaëlGI don't know. This might be a performance-killer, no?
Comment #4
Fabianx CreditAttribution: Fabianx commentedI think this really should just do a global drupal_static_reset() before and after even - else switching user accounts is not secure. As long as this is only called after cache clears, it should be fine as cache rebuilds are slow anyway.
Even better is it to use a sub request, but that has other problems in itself.
On the other hand just fixing for admin menu is enough for this issue, so RTBC for that.
Comment #5
Dave ReidIt's easy just to change this to a global drupal_static_reset(), so let's do that. Rather than needing a small followup for a small fix.
Comment #6
Dave ReidVersion that calls drupal_static_reset() whenever a global user object is changed.
Comment #8
Dave ReidTry this one again.
Comment #9
Dave ReidThat was the same thing, here's the revised version.
Comment #12
grisendo CreditAttribution: grisendo commentedThis is the related issue in Admin module: #2306821: Compatibility with XML Sitemap Menu
Comment #13
grisendo CreditAttribution: grisendo commentedThe combination of patch #1 with the Admin patch from #2306821: Compatibility with XML Sitemap Menu works for me.
I tried all, but I saw a couple of things about patches from #6, #8 and #9:
Comment #14
grisendo CreditAttribution: grisendo commented