With new PHP version a call to this module ends with

PHP Fatal error: Cannot re-assign auto-global variable _COOKIE

because of this PHP regression.

This problem can be easily resolved with renaming local variable $_COOKIE to something not conflicting with superglobal variables like

  function __construct($global_cookie) { // changed from function __construct($_COOKIE) and so on in whole function body
     if (isset($global_cookie["__utmz"])) {
       $this->utmz = $global_cookie["__utmz"];
     }
     if (isset($global_cookie["__utma"])) {
       $this->utma = $global_cookie["__utma"];
     }
       $this->ParseCookies();
  }

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iStryker’s picture

Status: Active » Closed (duplicate)

This is a duplication of #1198504: Deprecated split function used in gaparse class. In 5.3 its deprecated, 5.4 its removed.

ondra.knezour’s picture

Title: Incompatible with PHP 5.4 » Incompatible with PHP 5.4: Cannot re-assign auto-global variable _COOKIE
Status: Closed (duplicate) » Needs review

Changed title to be more descriptive. Please consider reading summary before your next action on issue, it is there for reason.

iStryker’s picture

Status: Needs review » Needs work

Create a patch then

fenstrat’s picture

Status: Needs work » Needs review
FileSize
656 bytes

Well tracked down @ondra.knezour

$cookies seems like the logical replacement. This fixes the error for me with PHP 5.4.

DickSwart’s picture

Status: Needs review » Reviewed & tested by the community

Patch worked for me thanx

Brian294’s picture

Status: Reviewed & tested by the community » Closed (fixed)

Thank you. Committed to 7.x branch. Will create a 7.4 version after the next git repo refresh.

Peace,
Brian

fenstrat’s picture

Thanks Brian.

When committing patches from other in the future please have a look Adding a commit author to help pay it forward.

ARUN AK’s picture

Patch worked for me. Thank you.

1658024-4-php_5.4_globals_regression.patch

themic8’s picture

The patch also worked for me, 1658024-4-php_5.4_globals_regression.patch

zkent’s picture

This patch (#4) worked for me also. I was setting up a local development copy of a working site and thought I was going nuts.