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!

Comments

mikeytown2’s picture

Category: bug » support

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.

/**
 * 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.

superfedya’s picture

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

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

mikeytown2’s picture

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

superfedya’s picture

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

mikeytown2’s picture

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.

superfedya’s picture

StatusFileSize
new67.29 KB

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

mikeytown2’s picture

StatusFileSize
new109.98 KB

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.

superfedya’s picture

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!

mikeytown2’s picture

StatusFileSize
new389 bytes

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

superfedya’s picture

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.

mikeytown2’s picture

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 » bug
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

AlexisWilke’s picture

It seems to me that the substring() is currently correct (unless we'd need end - 1 to remove the '#'? but substring() does not include the character pointed by end so I do think we're good.). However, I do not think we need the delimiters if we use the proper header. At this time, just changing the header breaks in my version (i.e. patch in #3).

At some point, I'll test without that ugly header and see if it works for me. If there is still a problem with other modules, we'll have to find a cleaner solution anyway.

Thank you for your research information.
Alexis Wilke