Dear all.
I hope I am writing in the correct forum about a small change.
I have just installed, again after more than 12 years of no usage, zen photo.
This has been the very and friendly way for me to share images.
When testing, I met a warning for deprecation, probably only shared with the Admin of the site. However, these might have impact on later version of PHP.
Here is the change I have done:
/zen-core/functions/functions.php
Changed line: 2251, 2254 and 2692 and replace ; by :
Apparently, the abandon is planed for release 9 of PHP but no dates are shared yet.
https://wiki.php.net/rfc/deprecations_php_8_5
Hope this helps.
Greetings
Valken
Hi acrylian,
I apparently can't edit my previous post, and I have to wait 24 hours between posts, so here is the additional information.
When browsing the Zenphoto site with PHP 8.5, the following warnings are displayed:
Deprecated: Case statements followed by a semicolon ( are deprecated, use a colon ( instead in /zen/zp-core/functions/functions.php on line 2251
Deprecated: Case statements followed by a semicolon ( are deprecated, use a colon ( instead in /zen/zp-core/functions/functions.php on line 2254
Deprecated: Case statements followed by a semicolon ( are deprecated, use a colon ( instead in /zen/zp-core/functions/functions.php on line 2692
All three warnings come from zp-core/functions/functions.php.
PHP has long accepted both a semicolon and a colon after a case label. However, the semicolon syntax is deprecated as of PHP 8.5 and is planned for removal in PHP 9.
Lines 2251 and 2254, in getAnonymIP(): case 0 and case 1 use a semicolon, while the other cases use a colon.
function getAnonymIP($ip, $anonymize = null) {
if (is_null($anonymize)) {
$anonymize = getOption('anonymize_ip');
}
$is_ipv6 = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
switch ($anonymize) {
case 0; // No anonymizing
return $ip;
default:
case 1; // Last fourth anonymized
if ($is_ipv6) {
return preg_replace('~[0-9a-zA-Z]*:[0-9a-zA-Z]+$~', '0:0', $ip);
} else {
return preg_replace('~[0-9a-zA-Z]+$~', '0', $ip);
}
case 2: // Last half anonymized
if ($is_ipv6) {
return preg_replace('~[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]+$~', '0:0:0:0', $ip);
} else {
return preg_replace('~[0-9a-zA-Z]*.[0-9a-zA-Z]+$~', '0.0', $ip);
}
case 3: // Last three fourths anonymized
if ($is_ipv6) {
return preg_replace('~[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]*:[0-9a-zA-Z]+$~', '0:0:0:0:0:0', $ip);
} else {
return preg_replace('~[0-9a-zA-Z]*.[0-9a-zA-Z]*.[0-9a-zA-Z]+$~', '0.0.0', $ip);
}
case 4: // Full anonymization, no IP stored
if ($is_ipv6) {
return '0:0:0:0:0:0:0:0';
} else {
return '0.0.0.0';
}
}
}
Line 2692
switch ($class) {
case 'error':
break;
case 'function';
Simply replace the semicolons with colons:
case 0; // No anonymizing → case 0: // No anonymizingcase 1; // Last fourth anonymized → case 1: // Last fourth anonymizedcase 'function'; → case 'function':This isn't a problem yet, but it will be once PHP 9 is released. See the PHP RFC: Deprecations for PHP 8.5
I hope this helps. And thanks again for Zenphoto: it's by far my favourite photo gallery, for its simplicity and ease of use!
Thanks for the report.
These and others have been fixed last august (https://github.com/zenphoto/zenphoto/commit/fdc5dc188fac09546ec2a2171524cbeaa6ee1c94) and will be available in the next release.
You can keep your own fixes until then. If you feel up to it you can also download and install the current master branch.
https://github.com/zenphoto/zenphoto/archive/refs/heads/master.zip