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.

Comments

mas5d2’s picture

mas5d2’s picture

Hmm. You could I guess key it as

'views_dom_id:' . $vars['dom_id'] . ':' . $view->name . ':' . $view->current_display

to 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.

dawehner’s picture

Status: Active » Needs work

Can you please look at the current version? There was something changed in between

jcisio’s picture

Version: 6.x-3.0-rc1 » 6.x-3.0
StatusFileSize
new18.62 KB

This bug is still there in 3.0. It happens in prod but not in dev.

I'll look at it.

jcisio’s picture

Well, 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.

jcisio’s picture

Title: Javascript settings key causes issues in caching » Possibly duplicate dom_id when output is cached
Version: 6.x-3.0 » 6.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new561 bytes

This 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.

jcisio’s picture

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

The 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