Where does this issue belong to? Core, redirect, token, media? ;)
Get raw version
- Call stack that causes the issue:
- - On boot the redirect module checks for redirect: redirect_load_entity_from_path ()
- - This builds the node, which attaches the fields
- - Having a text field with media token support triggers media_token_to_markup()
- - Loading the file to create the markup triggers file_entity_file_load()
- - This triggers token_replace() for the alt / title tags.
- - Token replacement triggers system_token_info()
- - This creates a link using l()
- - l() wants to know the current theme thus drupal_theme_initialize() is called.
- - drupal_theme_initialize() defines global variables e.g. $theme, $theme_key once those variables are set the main part of the function is skipped. Unfortunately drupal_theme_initialize() doesn't force menu_get_custom_theme() to initialize.
- Now what's the problem with that:
- The call of the redirect module is made before menu_set_custom_theme() was called, which is normally called after drupal_path_initialize() in _drupal_bootstrap_full().
- And the redirect module acts on hook_url_inbound_alter() which is triggered by drupal_path_initialize().
- Because that call is skipped hook_custom_theme() never is invoked and we loose the control over the theme.
- Two approaches:
- - Change drupal_theme_initialize() to force the initialization when calling menu_get_custom_theme()
- - Add a force flag to drupal_theme_initialize() to be able to re-set the global theming variables when calling the function in _drupal_bootstrap_full()