fooman / googleanalyticsplus

Magento Extension to add extra features to the default GoogleAnalytics module.
http://store.fooman.co.nz/extensions/magento-extension-googleanalyticsplus.html
100 stars 53 forks source link

Fatal error: Can't use method return value in write context #116

Closed Whizzzer closed 6 years ago

Whizzzer commented 6 years ago

I tried to install this plugin (plus the common one) via modman, but after clearing the cache it gave an error 500 on the webpage.

With some debugging enabled, it shows:

Fatal error: Can't use method return value in write context in /path/to/magento-site/includes/src/Fooman_GoogleAnalyticsPlus_Block_Universal.php on line 239

Which then should be this??

Disabling the module via app/etc/modules/Fooman_GoogleAnalyticsPlus.xml (and refreshing the cache) makes the website working again, yet without the plugin.

What am I doing wrong?

O, I'm running Magento 1.9.3.7..

fooman commented 6 years ago

It looks like you are using Magento's compilation mode. Please disable this before installing the extension and Rerun the compilation mode after finishing the installation.

fooman commented 6 years ago

Actually what version of php do you currently use?

Can you try changing

    return (
        Mage::getStoreConfigFlag('google/analyticsplus_optimize/enabled')
        && !empty($this->getGoogleOptimizeContainerId())
    );

to

    $containerId = $this->getGoogleOptimizeContainerId();
    return (
        Mage::getStoreConfigFlag('google/analyticsplus_optimize/enabled')
        && !empty($containerId)
    );
Whizzzer commented 6 years ago

During installation compilation mode was disabled (I followed the installation instructions)

I'm using PHP-FPM on CentOS in combination with Apache: [whizzer@server ~]$ php-fpm -v PHP 5.4.16 (fpm-fcgi) (built: Nov 15 2017 16:35:28) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies [whizzer@server ~]$ php -v PHP 5.4.16 (cli) (built: Nov 15 2017 16:33:54) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies [whizzer@server ~]$

Changing the code to the proposed one fixed the issue. Because my coding skills are "horrible", can you explain to me why the change fixed the problem?

hostep commented 6 years ago

@Whizzzer, it's a new feature in PHP 5.5 which is being used, the code won't work in PHP 5.4, see this page to see it was only added in PHP 5.5: http://php.net/manual/en/migration55.new-features.php#migration55.new-features.empty