create_function deprecated - Php 7.2 Joomla 3.9 CCv5

saol89 16 Nov, 2018
Can you help me?🙂
I have last versione of CCv5 on Joomla 3.9 with php 7.2 (i can't update to CCv6 now)

PHP Deprecated: Function create_function() is deprecated in administrator/components/com_chronoconnectivity5/chronoconnectivity/helpers/lister.php on line 218

PHP Deprecated: Function create_function() is deprecated in /libraries/cegcore/helpers/html.php on line 59

the line of error is this:
 $data_columns[$field]['function'] = create_function('$cell, $row', $functions[$k]);
healyhatman 17 Nov, 2018
https://stackoverflow.com/questions/48161526/php-7-2-function-create-function-is-deprecated

Just change the code, not sure when v5 will be updated
saol89 17 Nov, 2018
can you help me convert this?
 $data_columns[$field]['function'] = create_function('$cell, $row', $functions[$k]);
saol89 18 Nov, 2018
Thank🙂
saol89 18 Nov, 2018
instead, in the file
 /libraries/cegcore/helpers/html.php on line 59
the error is on the row "return...."
 public static function styles($styles = array()){
if(is_string($styles)){
return $styles;
}
(-->ERROR HERE) return implode('; ', array_map(create_function('$k,$v', 'return $k.":".$v;'), array_keys($styles), array_values($styles)));
}
GreyHead 18 Nov, 2018
Answer
1 Likes
Hi saol89.

The simplest fix is to set Site Error Reporting to System Default or to None which will prevent PHP Notices and Warnings from showing.

The other one is to replace the code as follows:

For the CC Notice try replacing :
create_function('$cell, $row', $functions[$k])
with
function($cell, $row) {return $functions[$k]}

NB I don't see the CC Error so can't check that this is correct!

For the CF notice in line 59 replace
create_function('$k,$v', 'return $k.":".$v;')
with
function($k, $v) {return $k.":".$v;}

Bob

NB You may need to retype these as copying code from the forum can include unwanted invisible characters!!!
saol89 20 Nov, 2018
Thank you Bob!
jpinto@anglo.edu.co 10 Jul, 2020
Hi Bob,

In my case I made the modifications indicated by Bob and the Warning is not shown but the values that the functions entered in the Php functions box should return do not work.
jpinto@anglo.edu.co 10 Jul, 2020
Hi, After evaluate a lot of alternatives it's now work.

PHP Deprecated:  Function create_function() is deprecated in administrator/components/com_chronoconnectivity5/chronoconnectivity/helpers/lister.php on line 218 
$data_columns[$field]['function'] = create_function('$cell, $row', $functions[$k]);
to
$functionsphp = $functions[$k];
$data_columns[$field]['function'] = function($cell, $row) use ($functionsphp) {return eval($functionsphp);};
This topic is locked and no more replies can be posted.