Gallerix module AJAX problem with IE.

superfedya - October 28, 2009 - 15:43
Project:Gallerix
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a problem with Gallerix module (AJAX fonction), so I tried to add gallery nodes to exception list, like this:
-Statically cache specific pages:
-Cache every page except the listed pages.
node/75 - my gallery node.

But this node always cached and annonym users cannot use AJAX gallery fonction with IE browser:
Webpage error details
Message: Invalid character
Line: 434
Char: 3
Code: 0
URI: http://www.madfanboy.com/site/sites/default/files/js/js_aba32314c4039c03...

Line 434: var json = eval('('+ content +')');

Thanks!

#1

mikeytown2 - October 28, 2009 - 20:46
Category:bug report» support request

Problem here is with the Gallerix Module. Module looks like it's abandoned; author used drupal_to_js() instead of drupal_json() when outputting JSON to the browser. Looks like he even made his own hack to get it to work.

<?php
/**
* All calls to print JSON for a Gallerix module should go through this wrapper function.
*
*/
function gallerix_to_js($data) {
 
//This delimiter is crucial, otherwise modules like devel will break JSON parsing.
 
return '##BEGIN_JSON##' . drupal_to_js($data) . '##END_JSON##';
}
?>

Anyway all calls to print gallerix_to_js should be replaced with drupal_json and the Boost & this module should work then.

As for the setting, when I go to node/75 I get a 404 which means that node doesn't exist. Make sure you have the right node id.

#2

superfedya - October 28, 2009 - 22:13

http://www.madfanboy.com/site/node/75 100% working.

So, if I am not a programmer, no way I can fix Gallerix?

#3

mikeytown2 - October 28, 2009 - 22:15

Put site/node/75 in the box then instead of node/75

#4

superfedya - October 29, 2009 - 19:04

I tried site/node/75, not effect.
But node/75 it is a working path, I use the same for blocks exception.

#5

mikeytown2 - October 30, 2009 - 00:54
Status:active» postponed (maintainer needs more info)

I just tried the

Statically cache specific pages:
[x] Cache every page except the listed pages.

Setting and it works... I need more info on your particular setup and the issue your encountering because code does work out of the box.

#6

superfedya - October 30, 2009 - 03:57

I just disable all my modules, except Boosts and Gallerix - same results. I tried on my shared hostig, as on localhost - always same result.

But, if I use Firefox or Chrome browser, Gallerix works perfectly with a Boost, problems only with a Internet Explorer...

AttachmentSize
fsdfdsfsd.jpg 67.29 KB

#7

mikeytown2 - October 30, 2009 - 04:56

http://drupal.org/patch/apply

Patch is extra large due to my text editor auto correcting white space issues in the module. All this does is replace print gallerix_to_js with drupal_json. You need to apply this patch to the gallerix module; Boost tends to bring out the flaws in code, including my own code.

See if the Cache every page except the listed pages. setting works with gallerix disabled.

AttachmentSize
gallerix-617038.patch 109.98 KB

#8

superfedya - October 30, 2009 - 16:58

Thanks!
I apply this patch on my localhost and now pictures dont load with any browser and even for auth users...

Line:108
Char:3
Code:0
Error:Syntax error
URL:http://localhost/site/modules/gallerix/js/common.js?b

Line 108 of common.js:
"var json = eval('('+ content +')');"

For exception list, I found a solution! I add this line to exception list: "gallerix/*" and its works!

#9

mikeytown2 - October 30, 2009 - 17:06

ah that makes since, it's doing a ajax call back under the path gallerix.

Sounds like the module creator baked in the ### code fairly heavily... Re-download a fresh copy to undo the patch I gave you. Try this one

AttachmentSize
gallerix.patch 389 bytes

#10

superfedya - November 1, 2009 - 01:54

Line:108
Char:3
Code:0
Error:Invalid character
URL:http://localhost/site/modules/gallerix/js/common.js?4

But ok, no problem, I add gallerix to my exception list.

#11

mikeytown2 - November 1, 2009 - 02:26
Title:Statically cache specific pages NOT working! Gallerix module AJAX problem with IE.» Gallerix module AJAX problem with IE.
Project:Boost» Gallerix
Version:6.x-1.13» 6.x-1.x-dev
Component:Miscellaneous» Code
Category:support request» bug report
Status:postponed (maintainer needs more info)» active

All I can say is wow... Here's the javascript code

/**
* A wrapper for parsing JSON. Unlike the original function, this
* wrapper does not break when Devel is printing SQL queries.
*
*
*/
Gallerix.parseJson = function (data) {

  // Only parse content in between the delimiters.
  var begin = data.indexOf('##BEGIN_JSON##');
  var end = data.lastIndexOf('##END_JSON##');
  var content = data.substring(begin + 14, end);
   
  var json =  eval('('+ content +')');
 
  json.remainder = data.substring(end + 12); 
 
  return json;
 
 
}

This code is the source of the issue var content = data.substring(begin + 14, end); The 14 number needs to be adjusted; or the end offset needs to be adjusted to the end at json.remainder = data.substring(end + 12);

I'm moving this over to the gallerix issue tracker.
http://drupal.org/project/issues/gallerix

Disable ajax caching in boost

 
 

Drupal is a registered trademark of Dries Buytaert.