Initial work to support PHP 7.2

This commit is contained in:
Rob Lensen 2018-01-17 23:40:27 +01:00
parent 9671454e75
commit 6a3f8f3e76
5 changed files with 10 additions and 8 deletions

View file

@ -675,7 +675,7 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
$datas = array();
$cat_map_callback = create_function('$m', 'global $cat_map; return $cat_map[$m[1]]["rank"];');
$cat_map_callback = function($m) use ($cat_map) { return $cat_map[$m[1]]["rank"]; };
foreach( $cat_map as $id=>$cat )
{
@ -1051,7 +1051,7 @@ SELECT id, uppercats, site_id
$categories = query2array($query);
// filling $cat_fulldirs
$cat_dirs_callback = create_function('$m', 'global $cat_dirs; return $cat_dirs[$m[1]];');
$cat_dirs_callback = function($m) use ($cat_dirs) { return $cat_dirs[$m[1]]; };
$cat_fulldirs = array();
foreach ($categories as $category)

View file

@ -402,7 +402,7 @@ CREATE TABLE '.$temporary_tablename.'
if ($flags & MASS_UPDATES_SKIP_EMPTY)
$func_set = create_function('$s', 'return "t1.$s = IFNULL(t2.$s, t1.$s)";');
else
$func_set = create_function('$s', 'return "t1.$s = t2.$s";');
$func_set = function($s) { return "t1.$s = t2.$s"; };
// update of table by joining with temporary table
$query = '

View file

@ -1399,11 +1399,13 @@ function safe_json_decode($value)
*/
function prepend_append_array_items($array, $prepend_str, $append_str)
{
array_walk(
/* array_walk(
$array,
create_function('&$s', '$s = "'.$prepend_str.'".$s."'.$append_str.'";')
);
*/
//New PHP 7.2 code
array_walk($array, function(&$value, $key) use($prepend_str,$append_str) { $value = "$prepend_str$value$append_str"; } );
return $array;
}
@ -2162,7 +2164,7 @@ SELECT COUNT(DISTINCT(com.id))
*/
function safe_version_compare($a, $b, $op=null)
{
$replace_chars = create_function('$m', 'return ord(strtolower($m[1]));');
$replace_chars = function($m) { return ord(strtolower($m[1])); };
// add dot before groups of letters (version_compare does the same thing)
$a = preg_replace('#([0-9]+)([a-z]+)#i', '$1.$2', $a);

View file

@ -290,7 +290,7 @@ class Template
return false;
}
reset($filename_array);
while(list($handle, $filename) = each($filename_array))
foreach ($filename_array as $handle => $filename)
{
if (is_null($filename))
{

View file

@ -617,7 +617,7 @@ Request format: ".@$this->_requestFormat." Response format: ".@$this->_responseF
static function ws_getMethodList($params, &$service)
{
$methods = array_filter($service->_methods,
create_function('$m', 'return empty($m["options"]["hidden"]) || !$m["options"]["hidden"];'));
function($m) { return empty($m["options"]["hidden"]) || !$m["options"]["hidden"];} );
return array('methods' => new PwgNamedArray( array_keys($methods),'method' ) );
}