Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
On a node page with an active redirect, the Redirect module causes an attempt to change the theme via hook_custom_theme() to fail to switch on first viewing. (The theme will successfully switch after reloading the page an extra time.)
I still need to know what is actually causing this besides "Redirect module". What code in redirect_init() is triggering this? I don't see anything in that function nor redirect_redirect() that would cause this.
My specific use case is: domain.module and domain_theme.module. I have a second domain setup with its own theme.
When saving a node on the second domain, the node will be rendered in the default theme. A refresh will load it in the correct theme. It's slightly more complicated than this. It only happens when using media tags in a body field.
The problem seems to stem from calling entity_load() in hook_url_inbound_alter().
In this case, the name module implements a theme callback to generate the users real name based off a name field.
IMHO, this is a core bug. But being realistic, having this fixed in core isn't going to happen in D7.
Currently, hook_custom_theme() fails if:
You call menu_get_item() within hook_custom_theme() [or any related menu item lookups]
theme() is invoked before menu_set_custom_theme()
[edit]
In response to the question, the entity_load() in redirect_url_inbound_alter() calls theme() which exposes a core bug that breaks the correct theme initialization.
Comments
Comment #1
dave reidNot clear at all from #1222536: Bug in Redirect module causes ThemeKey issue - Must page reload in browser to switch theme what the actual issue is.
Comment #2
mlncn commentedOn a node page with an active redirect, the Redirect module causes an attempt to change the theme via hook_custom_theme() to fail to switch on first viewing. (The theme will successfully switch after reloading the page an extra time.)
Comment #3
dave reidI still need to know what is actually causing this besides "Redirect module". What code in redirect_init() is triggering this? I don't see anything in that function nor redirect_redirect() that would cause this.
Comment #4
twistor commentedI'm running into this at the moment.
My specific use case is: domain.module and domain_theme.module. I have a second domain setup with its own theme.
When saving a node on the second domain, the node will be rendered in the default theme. A refresh will load it in the correct theme. It's slightly more complicated than this. It only happens when using media tags in a body field.
The problem seems to stem from calling entity_load() in hook_url_inbound_alter().
Comment #5
twistor commentedGlancing at the code, it doesn't seem to do anything. I'm not sure what the intended behavior is, but here.
Comment #6
mkalkbrennerSee https://drupal.org/node/1222536#comment-6036202
Comment #7
alan d. commented@Dave in regards to "I still need to know what is actually causing this besides "Redirect module"."
OK, there is a really crazy tangle of dependencies in the initialization of the theme and menu systems.
Generating the trace from within menu_get_custom_theme(), a common response is to get a trace like this:
But if the entity load triggers a theme() function, the first call would be something like:
In this case, the name module implements a theme callback to generate the users real name based off a name field.
IMHO, this is a core bug. But being realistic, having this fixed in core isn't going to happen in D7.
Currently, hook_custom_theme() fails if:
[edit]
In response to the question, the entity_load() in redirect_url_inbound_alter() calls theme() which exposes a core bug that breaks the correct theme initialization.
Comment #8
alan d. commentedMarked #1463010: Entity_load during url_inbound_alter is incompatible with text fields as duplicate. It too contains a patch to remove this function.
Comment #9
dave reidRather than removing it, I've commented it out for now.
http://drupalcode.org/project/redirect.git/commit/b655757