Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)
mlncn’s picture

Status: Postponed (maintainer needs more info) » Active

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.)

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

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.

twistor’s picture

Status: Postponed (maintainer needs more info) » Active

I'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().

twistor’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

Glancing at the code, it doesn't seem to do anything. I'm not sure what the intended behavior is, but here.

mkalkbrenner’s picture

alan d.’s picture

@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:

    menu_get_custom_theme(1)
    menu_set_custom_theme()
    _drupal_bootstrap_full()
    drupal_bootstrap(7)

But if the entity load triggers a theme() function, the first call would be something like:

menu_get_custom_theme()
drupal_theme_initialize()
theme_get_registry()
theme('name_component', Array)
_name_generate_tokens(Array, Array)
_name_format(Array, '((((t+ig)+im)+if)+is)+jc', Array)
name_format(Array, '((((t+ig)+im)+if)+is)+jc', Array)
name_user_load(Array)
call_user_func_array('name_user_load', Array)
DrupalDefaultEntityController->attachLoad(Array, )
UserController->attachLoad(Array, )
DrupalDefaultEntityController->load(Array, Array)
entity_load('user', Array)
redirect_load_entity_from_path('user/1')
redirect_url_inbound_alter('user/1', 'users/primary-administrator', NULL)
drupal_get_normal_path('users/primary-administrator')
drupal_path_initialize()
_drupal_bootstrap_full()
drupal_bootstrap(7)

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:

  1. You call menu_get_item() within hook_custom_theme() [or any related menu item lookups]
  2. 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.

alan d.’s picture

Marked #1463010: Entity_load during url_inbound_alter is incompatible with text fields as duplicate. It too contains a patch to remove this function.

dave reid’s picture

Status: Needs review » Fixed

Rather than removing it, I've commented it out for now.

http://drupalcode.org/project/redirect.git/commit/b655757

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.