system_token_info() has a call to l() in its date custom format definition. With the following modules enabled, this causes issues with theme initialisation:
- https://www.drupal.org/project/og_theme
- https://www.drupal.org/project/file_entity
- https://www.drupal.org/project/addressfield_tokens
This is because the following happens on the first load after cache clear:
- The theme is initialised, and hook_custom_theme() invoked.
- og_custom_theme() calls og_context(), which loads various entities, including a file
- file_entity_file_load() then replaces tokens in image alt/title text using token_replace().
- This invokes token_replace() which in turn invokes all implementations of hook_tokens().
- addressfield_tokens_tokens() is called, which calls token_info(), which calls system_token_info() which calls l()
- l() initialises the theme but we still haven't finished initialising the theme the first time around
This causes the custom theme to not be set correctly, until the second load of the page after cache clear.
The fault could lie be anywhere in the above call stack and to determine that, I guess we have to answer if it is reasonable for a hook_custom_theme() implementation to load entities (probably), if it is reasonable for a hook_tokens() implementation to call token_info() (maybe not) and if it is reasonable for a hook_token_info() implementation to call l() (probably).
Comment | File | Size | Author |
---|---|---|---|
#3 | core-token-info-initialise-theme-2483811-2.patch | 767 bytes | msmithcti |
#1 | core-token-info-initialise-theme-2483811-1.patch | 766 bytes | msmithcti |
Comments
Comment #1
msmithcti CreditAttribution: msmithcti at CTI Digital commentedThis patch is the simplest solution, but probably not the actual eventual fix needed here.
Comment #3
msmithcti CreditAttribution: msmithcti at CTI Digital commentedAh, syntax error there. Here's an updated patch.
Comment #4
DamienMcKennaIs this a duplicate of #2086335: Bootstrap issue with theme initialization causes hook_custom_theme() never to be invoked?
Comment #5
KeyboardCowboyPatch #3 will fix the issue in the system module, but contrib modules may also introduce the same error. Please see the issue in #4 for a more comprehensive option.
Comment #6
DamienMcKennaThe answer is yes, this is a duplicate of #2086335.