PHP short array syntax committed to 7.x-2.7

Created on 22 March 2023, over 1 year ago

Problem/Motivation

This is a follow-up to https://www.drupal.org/project/google_analytics/issues/3174214 ✨ Support Google Analytics 4/gtag.js Fixed 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.

πŸ› Bug report
Status

Fixed

Version

2.7

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jenlampton

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024