D7 bootstrap issue with drupal_theme_initialize() - draft

Public

Where does this issue belong to? Core, redirect, token, media? ;)

Get raw version
text
  1. Call stack that causes the issue:
  2.  
  3. - On boot the redirect module checks for redirect: redirect_load_entity_from_path ()
  4. - This builds the node, which attaches the fields
  5. - Having a text field with media token support triggers media_token_to_markup()
  6. - Loading the file to create the markup triggers file_entity_file_load()
  7. - This triggers token_replace() for the alt / title tags.
  8. - Token replacement triggers system_token_info()
  9. - This creates a link using l()
  10. - l() wants to know the current theme thus drupal_theme_initialize() is called.
  11. - 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.
  12.  
  13. Now what's the problem with that:
  14. 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().
  15. And the redirect module acts on hook_url_inbound_alter() which is triggered by drupal_path_initialize().
  16. Because that call is skipped hook_custom_theme() never is invoked and we loose the control over the theme.
  17.  
  18. Suggestion:
  19. Two approaches:
  20. - Change drupal_theme_initialize() to force the initialization when calling menu_get_custom_theme()
  21. - 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()

Comments