Closed (works as designed)
Project:
Drupal core
Version:
5.1
Component:
theme system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 May 2007 at 23:21 UTC
Updated:
27 Aug 2007 at 02:22 UTC
I'm working on sections-5.x module, what set's a $custom_theme in hook_menu() and i found a problem only exists with normal caching mode active. i cannot simply find what's wrong, but it looks like Drupal ignores $custom_theme variable if cache mode is active. This problem only comes up if i'm an anonymous user. I don't know how to trace down this problem!?
Someone able to give me a hint how to find the source of this problem or have a look to core code and gets an idea?
The "trace" module patch for 5.x is buggy and do not work with anonymous users... i'm a little bit lost!?
Comments
Comment #1
chx commentedif cache is on then the page is served from the... surprise! cache. theme system does not fire.
Comment #2
hass commentedWell, that's expected behavior and this is what makes me wonder. The frontpage is normally (without cache) displayed with 3 columns theme and after caching is enabled the page is displayed the 2 column standard layout :-(((. Both themes are active...
Any idea what *could* be wrong?
Comment #3
johnalbinIt sounds like the cache was created before the sections were set up.
Try:
The cache should then be created with the sections module’s modifications.
Comment #4
hass commentedOk, it took me MUCH and a HARD time to figure out what's broken here, but i found what happen. While this is a general problem i'd like to ask you what we can do to prevent this problem in general. I mark this critical, while it breaks the theme system.
Howto repro:
1. Create a menu item that have a theme placeholder like
'title' => t('Delete %name', array('%name' => $name))2. Add
3. Now a menu item containing the t() function calls function
t()4.
t()see the%nameand callstheme('placeholder', $value)5.
theme_get_function()does ainit_theme()and now all goes wrong...6. and prevent theme switching by modules, while $custom_theme cannot overwrite a previously set theme. The overwrite is prevented by
if (isset($theme)) { return; }ininit_theme().So i can only say today: Never ever should *any* module use
t()with%namein hook_menu OR init_theme() get's fired for theme_placeholder by theme_get_function function and theme switch will fail for anonymous users in cached mode with subthemes!Comment #5
hass commentedsorry, above code should be
if (!$may_cache) {Comment #6
drummDon't use hook_menu() for setting $custom_theme. Use hook_init().