I get this error when trying to enable the module:

PHP Fatal error: Can't use function return value in write context in /path_to_drupal/sites/all/modules/donations_thermometer/donations_thermometer.module on line 119

Line 119 contains this:

if( !empty(variable_get('donations_thermometer_block-' . $block_number . '-description')) ) {

I replaced the following code, including that line:

    $block_description = '';
    if( !empty(variable_get('donations_thermometer_block-' . $block_number . '-description')) ) {
      $block_description = variable_get('donations_thermometer_block-' . $block_number . '-description');
    }

with this:

$block_description = variable_get('donations_thermometer_block-' . $block_number . '-description','');

I was then able to enable the module and configure a thermometer block. However, I'm not sure my fix has really solved the issue. When I configured the module, I was then required to supply a description for the block before I could save it - I would have expected the code to supply a default description for the block.

Comments

millionleaves created an issue. See original summary.

millionleaves’s picture

Title: Can't enable under PHP 5.4 » Can't enable module

UPDATE: changed name to remove reference to PHP 5.4 - that was my initial reading of the error.

nazarioa’s picture

Status: Active » Postponed (maintainer needs more info)

Hello,
I just tried to reproduce this issue on an empty install of Drupal Core (version 7.41) with PHP v5.5.31. I was unable to reproduce it.
Anything else you can give me to help figure this out?
Maybe you had used an older version of donation thermometer previously?
Any info would be awesome.
Nazario

millionleaves’s picture

At the time I was installing it for the first time. Someone else ran the site for a while, and I've just come back to it. I've tried to update to 2.1 using Drush, and I'm getting this error:

Drush command terminated abnormally due to an unrecoverable error.                                                                                                          [error]
Error: Can't use function return value in write context in /home/username/public_html/sites/all/modules/donations_thermometer/donations_thermometer.module, line 119
The external command could not be executed due to an application error. 
Backups were restored successfully.   

Looks like the same error - the new version is overwriting the changes I made as outlined above, which is causing it to break again.

Site is running Drupal 7.43, with PHP 5.45.

johnrosswvsu’s picture

I create a patch to address this issue. Please check.

nazarioa’s picture

Hello John,
Thank you I will apply the patch now. Can you explain to me why this works?

nazarioa’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I applied the patch provided by the community. Thanks guy, much love.