Problem/Motivation

1. I upgraded my Drupal 7 installation to version 7.x-2.32 of this module via web-interface.
2. When I tried to perform cron action using web-interface in different ways, I received blank pages.
3. Then I tried to do so with drush and here's the output:

u11309@ocean ~/domains/mydomain $ drush cron
PHP Parse error:  syntax error, unexpected '[' in /home/u11309/domains/mydomain/sites/all/modules/advagg/advagg_js_compress/jshrink.inc on line 122
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                                               [error]
Error: syntax error, unexpected '[' in /home/u11309/domains/mydomain/sites/all/modules/advagg/advagg_js_compress/jshrink.inc, line 122

4. As a temporary work-around I disabled AdvAgg Compress Javascript sub-module. That allowed me to run cron without errors

P.S. it is worth to mention that it's the first time I noticed any errors with this module. Previous updates (using same method) were totally fine.

Proposed resolution

Fixing the typo in sites/all/modules/advagg/advagg_js_compress/jshrink.inc
OR for those who are not familiar with PHP (like me), you can simply disable AdvAgg Compress Javascript

User interface changes

The only change was blank page at /admin/config/system/cron

Comments

pick_d created an issue. See original summary.

pick_d’s picture

Issue summary: View changes
mikeytown2’s picture

Looks like an issue with older versions of php. I’ll get this fixed next week; patches welcome.

pick_d’s picture

Well, probably, yes. PHPinfo says it's version 5.3.29. And sorry, can't suggest any patch - not familiar with php :-(

nitesh sethia’s picture

StatusFileSize
new485 bytes

Simply changing the code from protected $stringDelimiters = ['\'', '"', '`']; to protected $stringDelimiters = ["\'", '"', '`']; will fix the error.

Added a patch for the same.

nitesh sethia’s picture

Status: Active » Needs review
StatusFileSize
new485 bytes

Simply changing the code from

protected $stringDelimiters = ['\'', '"', '`'];

to

protected $stringDelimiters = ["\'", '"', '`'];

will fix the error.

Added a patch for the same.

mikeytown2’s picture

Status: Needs review » Needs work

@Nitesh Sethia
That's not the correct fix here.

PHP Parse error: syntax error, unexpected '[' in advagg/advagg_js_compress/jshrink.inc on line 122

This is a bug due to the fact that in PHP 5.4 you can use short array syntax; but in php 5.3 it's not supported.

mikeytown2’s picture

Also the code change you did would have introduced a major bug into the jshrink code. See how your change makes the single quote into \'. That's bad.

$stringDelimitersA = ["'", '"', '`'];
$stringDelimitersB = ['\'', '"', '`'];
$stringDelimitersC = ["\'", '"', '`'];
print_r($stringDelimitersA, $stringDelimitersB, $stringDelimitersC);
mikeytown2’s picture

Status: Needs work » Needs review
StatusFileSize
new489 bytes

This should fix the error in php 5.3

  • mikeytown2 committed 997c944 on 7.x-2.x
    Issue #2947925 by mikeytown2: unexpected '[' in /sites/all/modules/...
mikeytown2’s picture

StatusFileSize
new579 bytes

This should make sure that all files get php 5.3 tested.

  • mikeytown2 committed 5d2183e on 7.x-2.x
    Issue #2947925 by mikeytown2: load all code for php sanity testing in...
mikeytown2’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.