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
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().
Offline
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
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
$sid = session_id(); $session_id = !$sid ? 'none' : $sid;
(untested).
Offline