Strange issue, and I'm not sure if domain is at fault or features, or possibly even a core bug. If domain theme is enabled, when visiting the view, status, diff or recreate paths for a specific feature drupal will display the content theme instead of the admin theme. To reproduce:
- Enable features
- Set a global admin theme
- Enable domain theme. It doesn't matter if you configure individual themes or other settings for the domains or not.
- Visit any screen for a specific feature, for example:
admin/structure/features/[some feature id] or admin/structure/features/[some feature id]/diff-- etc.
You'll see the site's content theme instead of the admin theme. Disabling domain_theme fixes the issue.
I've drilled the issue down to calling menu_get_item() in domain_theme_custom_theme(). Comment out that line and the problem goes away. I haven't looked thoroughly, but haven't seen any other pages that also exhibit those symptoms.
Comments
Comment #1
agentrickardOdd. I assumed this was a Features bug.
#1309128: View / Recreate feature ignores admin theme when menu_get_item() is used in hook_custom_theme().
I can find no reason, however, why this only happens on that particular page callback.
Comment #2
fearlsgroove commented@agentrickard: just in case you're not following the other issue you marked this as a dupe of, please check out the comment I left there. domain_theme is arguably partially responsible for this issue since it calls menu_get_item in hook_custom_theme, which happens before bootstrap. Since menu_get_item loads entities, which in turn invokes hooks that may assume Drupal is already bootstrapped, it's arguably unsafe to be called there.
Is it possible to do away with the menu_get_item call, or work around it? Commenting out that check does not seem to break context themes, admin theme or any other theme alter as far as I can tell.
Comment #3
fearlsgroove commentedChange status since maybe we can fix this issue in domain?
Comment #4
agentrickardThe status is correct. I goofed on the status change.
We need to research how $custom_theme is handled these days, since it seems to have changed since pre-alpha D7 when this code was written.
Comment #5
RonanLK commentedI had this problem, so I made a quick patch for domain, to avoid unnecessary calls to menu_get_item() in domain_theme_custom_theme() on admin pages.
It's far from a perfect solution, but it does the trick.
Comment #6
agentrickardarg() is a recipe for fail.
Comment #7
agentrickardPossibly a better patch in duplicate issue #1483542: Administrative theme
Comment #8
batigol commentedThis patch isn't working for me. Drupal admin theme is still changing to my custom theme (after clearing cache for example) even when I have set different Administration theme.
BTW after clearing cache and clicking on one of my subdomain links, the subdomain appear on my domain theme. However this is happening only once (after clear cache - reload page fix this) it's probably related with drupal caching.
Comment #9
alexverb commentedIt shouldn't be using menu_get_item() at all as stated in hook_custom_theme(). I think when the cache is cleared menu_get_item() somehow generates the default theme for the theme callback. And since the theme callback from hook_menu() always get's priority over hook_custom_theme() you end up with the default theme anyway.
I think we should ask ourselfs why we're checking for the theme callback and not path_is_admin() instead. I guess all other modules that use hook_custom_theme() should be weighted to get priority if needed.
Comment #10
agentrickardMakes sense. I think I wrote this piece before the D7 standards finalized.
Comment #11
tancHow about this quick patch? It checks that the current_path is path_is_admin and returns before menu_get_item.
Comment #12
batigol commented@tanc nope, this patch could not fix this issue for me. Same as #8.
Comment #13
agentrickardA quick review of the docs for hook_custom_theme and it looks like we let core handle it. The attached patch works for me under these conditions:
* Loads proper theme per domain.
* Loads proper admin theme.
* Loads proper per-domain admin theme.
Admin themes also work for content creation.
Comment #14
fearlsgroove commentedI had the same experience when I looked at this issue: after removing the code in your patch, I had no negative effects from themes set via context, administrative theme, domain theme, or even a custom module that using menu alter to set a custom theme for specific paths. I've been using essentially this code in production for a couple months now on a number of production sites with issues.
Comment #15
batigol commented@agentrickard I have tested this patch, well after applied I simply clear cache and my domain theme appear on the screen... I still have issue with DA and my domains/subdomains themes.
I have set and configured proper theme for each domain, I set proper admin theme (seven) in every of my domains/subdoamins and still nothing.
After an hour of testing:
I have installed Commerce among with few other contrib modules (Address Field, Entity API, Rules, Entity Translation etc.) lately. So I did a little digging and it seems that PayPal WPS (PayPal Website Payments Standard) (!?) module is causing this issue for me and it's not even related with domain theme (in my particular case)
...
I just feel like a wizard cause magic is happen here, or something is seriously FU with my site...
Comment #16
alexverb commentedWhopsiedaysie, I should be renaming myself to mr.dupe. Sorry, ignore this patch.
Comment #17
agentrickard@alexverb
That is a duplicate of the patch in #13. Please don't confuse reviewers by posting duplicate patches. REVIEW the existing patch.
Comment #18
agentrickardSo the patch works for you, yes?
Comment #19
alexverb commentedI've had no issue's since the patch in #13 has been applied.
Comment #20
agentrickardOK. I'm going to commit and let people file new issues if they come up.
Comment #21
agentrickardCommitted to 7.x.3.
Comment #22
agentrickardApplies cleanly to 7.x.2.
Comment #24
alan d. commentedThanks. I just spent the last couple of hours debugging this to find that it already fixed :)
Right, two modules in play and the other one does requires the line
$item = menu_get_item();Comment #25
jeffschulerCross-referencing #2347825: CustomError causing admin pages to appear in default theme, where the same issue occurs with the CustomError module due to a call to
menu_get_item()fromhook_custom_theme().