[Piwigo 2.9.2 and PHP 7.2.0] Incompatible code in gallery/include/functions.inc.php and /include/template.class.php #734

Closed
opened 2026-10-05 00:14:34 +02:00 by adam · 14 comments
Owner
Deprecated: Function create_function() is deprecated
in /gallery/include/functions.inc.php on line 2165

Deprecated: The each() function is deprecated.
This message will be suppressed on further calls 
in /gallery/include/template.class.php on line 293
  • piwigo 2.9.2
  • debian 9
  • php 7.2.0
``` Deprecated: Function create_function() is deprecated in /gallery/include/functions.inc.php on line 2165 Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /gallery/include/template.class.php on line 293 ``` * piwigo 2.9.2 * debian 9 * php 7.2.0 <!-- github-sync-id:279139238 -->
adam closed this issue 2026-10-05 00:14:34 +02:00
Author
Owner

Here we go, first incompatibilities with the latest version of PHP :-) If you have coding skills, you may already know how to fix this and keep the code compatible with older versions of PHP (at least PHP 5.4) ? (I will soon install PHP 7.2 on a test environment)

Here we go, first incompatibilities with the latest version of PHP :-) If you have coding skills, you may already know how to fix this and keep the code compatible with older versions of PHP (at least PHP 5.4) ? (I will soon install PHP 7.2 on a test environment) <!-- github-comment-id:349097677 -->
Author
Owner

@plegall Yes, I will try. I already found several plugins not working with piwigo 2.9.2 and php 5.x (this is another issue).

While we are talking, but off-topic here: is there something like a drag&drop function to move images and folders to another location?

@plegall Yes, I will try. I already found several plugins not working with piwigo 2.9.2 and php 5.x (this is another issue). While we are talking, but off-topic here: is there something like a drag&drop function to move images and folders to another location? <!-- github-comment-id:349099496 -->
Author
Owner

I just got hit by this after and update this evening.

Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165
Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165
Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165
Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /usr/share/webapps/piwigo/include/template.class.php on line 293

First four are the "Batch Downloader", "Header Manager", "Thumbnail Tooltip", and "UserAdvManager". If I disable those, they go away.

Also, forgive me if I am wrong, but having these php errors show up even on the main page without login is a bit of a security risk correct? Seems like these should only post when a user is logged in, or even better only for admins.

Piwigo 2.9.2
Operating system: Arch Linux
PHP: 7.2.0 (Show info) [2017-12-08 20:39:21]
MySQL: 5.5.5-10.1.29-MariaDB [2017-12-08 20:39:21]
Graphics Library: External ImageMagick 6.9.9-25

I just got hit by this after and update this evening. ``` Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165 Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165 Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165 Deprecated: Function create_function() is deprecated in /usr/share/webapps/piwigo/include/functions.inc.php on line 2165 Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /usr/share/webapps/piwigo/include/template.class.php on line 293 ``` First four are the "Batch Downloader", "Header Manager", "Thumbnail Tooltip", and "UserAdvManager". If I disable those, they go away. Also, forgive me if I am wrong, but having these php errors show up even on the main page without login is a bit of a security risk correct? Seems like these should only post when a user is logged in, or even better only for admins. Piwigo 2.9.2 Operating system: Arch Linux PHP: 7.2.0 (Show info) [2017-12-08 20:39:21] MySQL: 5.5.5-10.1.29-MariaDB [2017-12-08 20:39:21] Graphics Library: External ImageMagick 6.9.9-25 <!-- github-comment-id:350414004 -->
Author
Owner

As far as I understand for now, we have to replace create_function by anonymous function (closure) which is only available starting on PHP 5.3. Meaning, Piwigo can be compatible with PHP 7.2 if we drop compatibility with PHP 5.2 (I don't say it's a good idea, just a fact). Of course today I think it's more important to be compatible with PHP 7.2 than 5.2 ;-)

As far as I understand for now, we have to replace create_function by anonymous function (closure) which is only available starting on PHP 5.3. Meaning, Piwigo can be compatible with PHP 7.2 if we drop compatibility with PHP 5.2 (I don't say it's a good idea, just a fact). Of course today I think it's more important to be compatible with PHP 7.2 than 5.2 ;-) <!-- github-comment-id:350449519 -->
Author
Owner

@plegall Yes, you are correct. Such internal structure information should always be suppressed. This is what for example MediaWiki does (do not show internal information in case of warnings, errors, crashes).

@plegall Yes, you are correct. Such internal structure information should always be suppressed. This is what for example MediaWiki does (do not show internal information in case of warnings, errors, crashes). <!-- github-comment-id:350646623 -->
Author
Owner

i have the same issue with php7.2 on archlinux. is it possible to disable error displaying in the piwigo? it seems gallery works just fine and in my php.ini i have display_errors = Off thus I am not grasping why are the errors displayed in the browser?

edit: ... ok found answer in the source:

add $conf['show_php_errors'] = E_NONE;
to local/config/config.inc.php

i have the same issue with php7.2 on archlinux. is it possible to disable error displaying in the piwigo? it seems gallery works just fine and in my php.ini i have display_errors = Off thus I am not grasping why are the errors displayed in the browser? edit: ... ok found answer in the source: add $conf['show_php_errors'] = E_NONE; to local/config/config.inc.php <!-- github-comment-id:351159270 -->
Author
Owner

The create_function() and eval() should be replaced.

The create_function() and eval() should be replaced. <!-- github-comment-id:382061409 -->
Author
Owner

When trying to see 'users' I get the following error:
(Is this part of the same problem with php7.2 ?)

DataTables warning: table id=userList - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

When trying to see 'users' I get the following error: (Is this part of the same problem with php7.2 ?) DataTables warning: table id=userList - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1 <!-- github-comment-id:390034431 -->
Author
Owner

Hi;
maniac0r you wrote:

add $conf['show_php_errors'] = E_NONE;
to local/config/config.inc.php

Well actually on my 2.9.3 gallery both $conf['show_php_errors'] = true; and $conf['show_php_errors'] = false; are working, but E_NONE is not.

Hi; maniac0r you wrote: > add $conf['show_php_errors'] = E_NONE; > to local/config/config.inc.php Well actually on my 2.9.3 gallery both _$conf['show_php_errors'] = true;_ and _$conf['show_php_errors'] = false;_ are working, but _E_NONE_ is not. <!-- github-comment-id:390667179 -->
Author
Owner

Hi,
my config is php 7.2.3

i re write the source code of functions.inc.php

first time i have :
// $replace_chars = create_function('$m', 'return ord(strtolower($m[1]));');

i replace by

$replace_chars = function($m) {
return ord(strtolower($m[1]));};

i do the same thing in MultiView.class.php

// $this->data_url_params = array_map(create_function('$d', 'return "ato_".$d;'), $this->data_url_params);
$this->data_url_params = array_map(
function ($d){
return "ato_".$d;},
$this->data_url_params);
}

Hi, my config is php 7.2.3 i re write the source code of functions.inc.php first time i have : // $replace_chars = create_function('$m', 'return ord(strtolower($m[1]));'); i replace by $replace_chars = function($m) { return ord(strtolower($m[1]));}; i do the same thing in MultiView.class.php // $this->data_url_params = array_map(create_function('$d', 'return "ato_".$d;'), $this->data_url_params); $this->data_url_params = array_map( function ($d){ return "ato_".$d;}, $this->data_url_params); } <!-- github-comment-id:391963242 -->
Author
Owner

re hi
in template.class.php
my case is

// while(list($handle, $filename) = each($filename_array))
foreach ($filename_array as $handle=>$filename)

re hi in template.class.php my case is // while(list($handle, $filename) = each($filename_array)) foreach ($filename_array as $handle=>$filename) <!-- github-comment-id:391968801 -->
Author
Owner

Piwigo 2.9.4 has fixed incompatibilities with PHP 7.2

Piwigo 2.9.4 has fixed incompatibilities with PHP 7.2 <!-- github-comment-id:407323285 -->
Author
Owner

I'm on 2.10.1 and am still having this issue. I upgraded from 2.9.something and since then trying to edit users produces "DataTables warning: table id=userList - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1". PHP also upgraded from 5 to 7.3

I'm on 2.10.1 and am still having this issue. I upgraded from 2.9.something and since then trying to edit users produces "DataTables warning: table id=userList - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1". PHP also upgraded from 5 to 7.3 <!-- github-comment-id:551297993 -->
Author
Owner

@drder66 i have just found a fix, in file ./admin/user_list_backend.php look for all occurrences of "AS" and put the "as parameter" into the reversed quotes ( ` ).

i can see it's already patched here in master repo.

i am using php-7.4.0 and MariaDB 10.4.7 (MySQL8.0.16).

@drder66 i have just found a fix, in file ./admin/user_list_backend.php look for all occurrences of "AS" and put the "as parameter" into the reversed quotes ( ` ). i can see it's already patched here in master repo. i am using php-7.4.0 and MariaDB 10.4.7 (MySQL8.0.16). <!-- github-comment-id:571645289 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#734