Path conditions are evaluated in context_init, and just call context_set() in order to set the active context when it matches. Other conditions (specifically menu_trail) do not -- they are run when the context_page_condition hook is run. Further they run context_set_by_condition, not context_set, which in turn does NOT set a new context when one is already set.

The end result is that the trick of setting an alphabetically first sitewide context as a default does not work. What's more, the only context that will ever evaluate as true is one with a path condition if any path condition matches. This seems like a bit of a logic bomb to me.

Either the path check should be moved from context_init and run with set_context_by_condition (why isn't it??), or even better, force should be true by default, in which case it should probably just be removed in favor of assuming modules that call it will run context_isset before calling context_set if they don't want to overwrite.

Comments

fearlsgroove’s picture

Minor correction: context_init will set a path argument if matched, or a sitewide argument if no path is matched, but a sidewide is set. I'd argue that sitewide should be set in default, but context_set should ALWAYS overwrite.

steven jones’s picture

Hmmm...It would seem that the only conditions that can 'override' a sitewide context at the moment are path conditions.

Given that using sitewide contexts in this manner is pretty much a hack anyway, I'm tempted to say that this behaviour just needs better documentation.

I don't want to change the default argument of context_set_by_condition to $force = TRUE, as that may well break a lot of sites.

steven jones’s picture

I have a cunning plan and a fix!

steven jones’s picture

Status: Active » Fixed

I've added a 'default' context condition so that we can stop using the sitewide context in the hacky way it was never meant to be used.

Fixed in http://drupal.org/cvs?commit=361078

Status: Fixed » Closed (fixed)

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