Problem:
Adding a "Context Exists" visibility rule to a content pane grants grants access if ANY context exists, not just if the selected context exists.
To reproduce:
1. Add an optional term reference field to a content type
2. Enable the node_view panel page
3. add a context relationship to the panel page term reference field created in step 1
4. Add a content pane (anything is fine)
5. Add a "Context Exists" visibility rule to that content pane and select the term reference relationship context you added in step 3.
6. View a node that doesn't have a taxonomy term selected (for the field from step 1) and notice that the content pane is visible even though
it's configured to be visible only if the taxonomy term context exists.
[Update]
Latest patch in Comment #11
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | ctools-context-exists-access-plugin-1263896-11.patch | 2.01 KB | setvik |
| #10 | ctools-context-exists-access-plugin-1263896-8.patch | 2.01 KB | setvik |
| #8 | ctools-context-exists-access-plugin-4923364-3.patch | 614 bytes | setvik |
| #3 | ctools-context-exists-access-plugin-4923364-3.patch | 614 bytes | setvik |
Comments
Comment #1
setvik commentedComment #2
setvik commentedComment #3
setvik commented[UPDATE]
The attached patch doesn't work. Don't use it
Comment #4
merlinofchaos commentedThe 'any' just means that any context can be used to satisfy the condition.
Though hmm. I suppose fallback code to try and match up contexts that have been renamed might actually be at issue here. Are you 100% sure that actually fixes the problem? It still allows any context to actually be selected?
Comment #5
setvik commentedHere's what i found so far:
The patch above definitely fixed the issue i was having and made it so that the "context exists" visibility rule returned true only when the context specified in the rule configuration existed.
Before removing the "any" the context exists rule was returning TRUE in the node_view panel regardless of whether the context i had specified existed or not.
I tried debugging and found that if the specified context exists ctools_context_required::select() returns that context as expected.
But if the context isn't present, ctools_context_required::select() does the fallback you mentioned looking for contexts with changed IDs.
It delegates this to ctools_context_required::filter() which runs through all present contexts and returns any matching the "required" context specified in the plugin configuration (in context exists' case, that's "any" which all contexts will match), so ctools_context_required::filter() ends up returning the unwanted node_view node context (in my case).
I've only tested so far with the taxonomy term context that i added to my node_view panel.
I'll test it with some other contexts and get back with the results.
Comment #6
setvik commentedackk... you're right.
the patch only fixed the problem b/c I added the visibility rule before making the patch...
I just tried removing the visibility rule and now the "context exists" visibility rule option doesn't even appear...
"I suppose fallback code to try and match up contexts that have been renamed might actually be at issue here."
Yeah, that seems to be what was causing my problem. i'm not sure how to fix it though...
Comment #7
merlinofchaos commentedProbably an extra parameter to the ctools_context_required object with a way to say not to fall back to another context.
The fallback code is in ctools_content_select_context() if it helps.
Comment #8
setvik commentedTake #2.
Rolling a new patch that adds a $skip_name_check parameter to the ctools_context_required object, tests for it in ::select() & only executes the fallback code if the parameter is present.
Comment #9
setvik commentedComment #10
setvik commentedTake #3,
Here's the correct patch
Comment #11
setvik commentedTake #4,
Here's the correct patch with the correct file name.
Comment #11.0
setvik commentedUpdating summary to point at latest patch
Comment #11.1
setvik commentedpatch location update
Comment #12
capellicThis patched work for me, thanks!
Comment #13
Kitbash commentedThis patch has saved my bacon -- many thanks!
Comment #14
setvik commentedSetting to RTBC
Comment #15
capellicHas this patch been applied to the DEV version? I need to update this module to get another update that did (http://drupal.org/node/1167938)-- I guess I'll apply that patch until at which time this is also committed to the DEV version.
THANK YOU!
Comment #16
merlinofchaos commentedExcellent answer. Committed! THanks!
Comment #17.0
(not verified) commentedlatest patch update