Problem/Motivation
This is a follow-up to https://www.drupal.org/project/google_analytics/issues/3174214 where I mentioned that updating to 7.x-2.7 immediately crashed my site with no errors in the logs.
I was able to determine that it was in fact a PHP version issue, as some code using the short array syntax was committed.
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: syntax error, unexpected '[' in
/var/www/html/sites/all/modules/contrib/google_analytics/googleanalytics.module, line 457
// Drupalism: When empty, $account->data is a boolean, not an array.
if (!is_array($account->data)) {
$account->data = [];
}
should be
// Drupalism: When empty, $account->data is a boolean, not an array.
if (!is_array($account->data)) {
$account->data = array();
}
If we are expecting everyone using this module to be able to handle the short array syntax, we should add a requirements check so that people who cannot run this version do not attempt to update to it.
Comments
Comment #2
jenlamptonThis old server appears to be running PHP 5.6, but I think the short array syntax was introduced in PHP 5.4?
I'm not sure exactly how I'm having this problem, but this patch did fix it for me ¯\_(ツ)_/¯
Comment #3
mglamanOh, wow, thanks. I'll commit this patch tomorrow and make another release. Thanks for finding the root cause.
Comment #5
mglamanThank you! Committed. I am actually waiting to release to review any other issues, I'll release next week.