CustomError 7.x-1.2 is causing the default theme to be used on certain administration pages (in non-error situations entirely) instead of the admin theme.
For me this is happening on Features' Review Overrides pages (/admin/structure/features/[featurename]/diff) and upon saving views.
customerror_custom_theme() (added in 7.x-1.2 in commit #6b3f920) is triggering a call to menu_get_item() via drupal_valid_path(). When menu_get_item() is called before Drupal's main bootstrap process like this, it can initialize the theme system too early.
This has happened in other modules. See:
- Sub-pathauto: #1814516: Subpathauto causing admin pages to appear in default theme
- Domain Access: #1419090: Domain theme, admin theme broken broken for certain paths in Features module
- #1309128: View / Recreate feature ignores admin theme when menu_get_item() is used in hook_custom_theme().
Looks to be a core bug, ultimately, and this whole subsystem has been redone in D8: #1954892: Replace 'theme callback' and hook_custom_theme() with a clean theme negotiation system.
Is there a way we can get around it in D7?
Some way we can avoid calling get_menu_item() from hook_custom_theme()?
In that same commit to CustomError (#6b3f920) a theme callback was added:
$items['customerror'] = array(
'title' => 'customerror',
'access callback' => TRUE,
'page callback' => 'customerror_page',
'theme callback' => 'customerror_theme_callback',
'type' => MENU_CALLBACK,
);
The customerror_theme_callback() callback function is not defined in the module, though. I tried defining it and, inside it, doing essentially what hook_custom_theme() does, but CustomError's theme callback does not get triggered on error pages; only when loading the URL customerror/[errcode] directly.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | customerror-hook_custom_theme_order-2347825.patch | 513 bytes | jeffschuler |
Comments
Comment #1
jeffschulerComment #2
gisleNot that I am aware of.
Comment #3
jeffschulerThanks for the quick response, @gisle.
I don't believe this issue to be a duplicate of #278575: Admin theme is used on error pages below /admin; the issues describe quite different resulting problems.
To help minimize some of the trouble caused, can we change the order of conditionals in
customerror_custom_theme()so the problem described in this issue won't occur if there is no custom theme set for CustomError?Comment #4
gisleOK, I'll try to find some time to look at it.
The addition of
customerror_theme_callback()in the commit you refer to was is the remains of a (failed) attempt to fix the bug you say this is not a duplicate of.(The presence of a
theme_callbackdefintion without a callback function in 7.x-1.2 is confusing and it should have been removed after it was determined that it did not have the desired effect. I'll make sure it is gone in the next snapshot.)Comment #5
jeffschulerThanks.
Just for reference, it looks like someone else has had issues with theme_callback and error pages: How can can I get theme callback to work for an error page? | Drupal Answers. No good answers there, either, (including the suggestion to use menu_get_item() in hook_custom_theme()).
Comment #7
gisleThis has been committed to the latest snapshot release of 7.x-1.x-dev, and will be included in the next regular release.
Comment #8
sgdev commentedThanks for making this patch, much appreciated!
A quick comment for anyone planning to use the patch in #3 -- there seems to be a formatting issue with the file. Just add the change manually and it will take care of the problem.
Comment #9
gisle@ron_s wrote:
Or you may download the lastest snapshot of the 7.x-1.x branch from the repo. The patch has been included.
Comment #10
sgdev commentedJust to confirm... did you mean 3.x or 1.x?
Comment #11
gisleSorry. I meant 7.x-1.x (there is no 7.x-3.x). Corrected.
Comment #12
cthshabel commentedWOW... that was concerning. we have recently done a lot of different development changes and this we noticed.
thanks a lot for the patch and the keywords in this queue. I was able to quickly find this and things are working again with the patch in #3.
Thanks!
Comment #13
gisleI am setting this to fixed in release 7.x-1.3. It probably cannot be fully resolved until D8, tho' - see comment #2.