Issue #1303880 included a fix that causes javascript settings to be keyed based off the dom_id. When caching is turned on, that dom_id is never updated. This causes issues when a views block is placed on a page after it has been cached when it's dom_id is taken by another block. We get duplicate settings in that key.
The settings for the duplicate key look like this:
"views_dom_id:7":{"view_name":["announcements","my_groups"],"view_display_id":["block_1","block_2"],"view_args":["",""],"view_path":["dashboard","dashboard"],"view_base_path":[null,null],"view_dom_id":[7,7],"pager_element":["0",0]}}}
instead of
"views_dom_id:7":{"view_name":"announcements","view_display_id":"block_1","view_args":"","view_path":"dashboard","view_base_path":null,"view_dom_id":7,"pager_element":"0"}
That will lead to ajax errors in ajax_view.js (line 61) that look like:
Uncaught TypeError: Object announcements,my_groups has no method 'replace'.
The JavaScript is expecting a string and gets an object instead.
My quick solution is to add a random number to the end of the key. With a high enough random number, collisions should be pretty low. There is probably a better solution out there though.
Patch will be included.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | views-1395352-output-cache-6.patch | 561 bytes | jcisio |
| #4 | 20120714213904.png | 18.62 KB | jcisio |
| #1 | javasript-settings-key-cache-fix-1395352-1.patch | 588 bytes | mas5d2 |
Comments
Comment #1
mas5d2 commentedComment #2
mas5d2 commentedHmm. You could I guess key it as
'views_dom_id:' . $vars['dom_id'] . ':' . $view->name . ':' . $view->current_displayto make it more unique than a random number. You'd still run into an issue trying to display the same view twice on one page after it's been cached, so maybe still have the number but with the view->name and view->current_display.
Comment #3
dawehnerCan you please look at the current version? There was something changed in between
Comment #4
jcisio commentedThis bug is still there in 3.0. It happens in prod but not in dev.
I'll look at it.
Comment #5
jcisio commentedWell, patch #1 did not help. However I think I got the cause.
When a view is displayed twice (or two views with different arguments but having the same result), template_preprocess_views_view() happens only once, so the second view always takes the dom_id of the first one.
Comment #6
jcisio commentedThis patch fixes it by adding arguments into cache key. It is necessary because we usually don't display a view more than once in a page, but using Panels, it is fairly frequent that a same view is embedded multiple times in a page with different arguments sent from Panels.
Comment #7
jcisio commentedCross reference with issue in D7 #1055616: Query arguments should be replaced before generating cache ID
Comment #8
chris matthews commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed, please see issue #3030347: Plan to clean process issue queue