API page: http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct...

This hook works well if the theme selection is based on different url. But if a same path can have different themes this seems to make anonymous page caching impossible. A mention about this possible issue would be nice.

The only possible workaround I've found so far is to override the cache_* functions like this:
http://drupalcode.org/project/mobile_tools.git/blob/refs/heads/7.x-2.x:/...

Comments

jhodgdon’s picture

Title: Add warning about anonymous page caching » Add warning about anonymous page caching to hook_custom_theme() docs
Issue tags: +Novice, +Needs backport to D7

The URL above didn't work for me. I found it at:
http://api.drupal.org/api/drupal/core!modules!system!system.api.php/func...
http://api.drupal.org/api/drupal/modules!system!system.api.php/function/...

Anyway, adding a note that it won't work with page caching seems like it would make sense.

nmudgal’s picture

Status: Active » Needs review
StatusFileSize
new676 bytes

Added message:

Due to possibility of different theme on same path, anonymous page caching may not work.

But it seem to clash with this a bit (right below it):

Since only one theme can be used at a time, the last (i.e., highest weighted) module which returns a valid theme name from this hook will prevail.
jhodgdon’s picture

Status: Needs review » Needs work

I don't think it conflicts with the next statement... but I don't think this added text quite gets the point across (and it needs a little grammatical help, like some extra "the" and "a" words added)... How about something more like this:

Note that returning different themes for the same path may not work with page caching. This is most likely to be a problem if an anonymous user on a given path could have different themes returned under different conditions.

Does that make more sense?

nmudgal’s picture

Assigned: Unassigned » nmudgal
nmudgal’s picture

I think the text you proposed is creating a bit of redundancy [ multiple use of 'different', 'returned' ] etc.
So reworded it a bit [ Not changing status ]

Note that returning different themes for the same path may not work with page caching. This is most likely to be a problem for an anonymous user under same
condition.

Let me know if it is fine then will create patch.

Thanks

jhodgdon’s picture

The second sentence doesn't tell me enough to figure out what the problem would be.

nmudgal’s picture

How about this ?

For an anonymous user, page caching may not work under the conditions of returning different themes for the given path.
jhodgdon’s picture

I still like my proposal in #3 better than this alternative...

How about this?

Note that returning different themes for the same path may not work with page caching. Since most page caching is only for anonymous users, this is only likely to be a problem if you plan to return different themes under different conditions for anonymous users accessing the same path.

nmudgal’s picture

Status: Needs work » Needs review
StatusFileSize
new817 bytes

well #3 makes more sense than #8 :-)
created patch but still I think we should wait for more review & see if someone can suggest better?

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

nmugdal: I am OK with #9 (obviously). If you want others to review it, please find them and ask them to review. Otherwise I will just commit it. Tentatively setting to RTBC status.

Tor Arne Thune’s picture

+1 on the RTBC. It's quite clear from the new text why the case you mentioned is not compatible with anonymous page caching.

nmudgal’s picture

Okay then I suppose we can mark it "fixed".
go go go, commit it jhodgdon :-)

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x/7.x. Thanks!

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