Announcement

#1 2023-05-16 16:13:15

funky_turtle
Member
2023-05-16
2

Upgrade issues

Hi All!
I was upgrading from v2.6 maybe to v 13.something. All seemed to be going well and then when I visit the site it gives me the below error:-

Fatal error: Can't use function return value in write context in /var/www/web/piwigo/include/functions.inc.php on line 602

    $details['sync'] = true;
  }

  if ('tag' == $object and 'delete' == $action and isset($_POST['destination_tag']))
  {
    $details['action'] = 'merge';
    $details['destination_tag'] = $_POST['destination_tag'];
  }

  $inserts = array();
  $details_insert = pwg_db_real_escape_string(serialize($details));
  $ip_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null;
  $session_id = !empty(session_id()) ? session_id() : 'none';                                                 LINE 602

  foreach ($object_ids as $loop_object_id)
  {
    $performed_by = $user['id'] ?? 0; // on a plugin autoupdate, $user is not yet loaded

    if ('logout' == $action)
    {
      $performed_by = $loop_object_id;
    }

Offline

 

#2 2023-05-16 19:11:53

erAck
Only trying to help
2015-09-06
2026

Re: Upgrade issues

As you mentioned "upgrading from v2.6", are you by chance also using a very very very old and completely outdated PHP version like 5.4?

Anyway, the code misuses empty(), which is not a function but a PHP language construct that operates on references (in earlier PHP versions only on variable references and only since 5.5 on other references, hence the question about your PHP version) and does nothing else than  !isset($ref) || !$ref  but as a function always returns something (thus the result is set) an empty(func()) effectively returns only the result of !$ref where $ref is the result of func().


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2023-05-17 12:48:29

funky_turtle
Member
2023-05-16
2

Re: Upgrade issues

Hi,

I was running an old version, but it is now running 8.1.
I still get the error though.
Is there anything I can do to fix it?

Thanks
Keith

Offline

 

#4 2023-05-17 18:18:43

erAck
Only trying to help
2015-09-06
2026

Re: Upgrade issues

I'd rather use PHP 8.0 because 8.1 is overly picky with some code that Piwigo and specifically extensions are not prepared for.

However, you could try to replace that line
$session_id = !empty(session_id()) ? session_id() : 'none';
with

Code:

  $sid = session_id();
  $session_id = !$sid ? 'none' : $sid;

(untested).


Running Piwigo at https://erack.net/gallery/

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact