Don't use create_function() deprecated in PHP 7.2

pull/5890/head
Aleksander Machniak 7 years ago
parent 0c3af6b950
commit 169cbc8c13

@ -1472,16 +1472,23 @@ class rcube_ldap extends rcube_addressbook
if (strpos($templ, '(') !== false) {
// replace {attr} placeholders with (escaped!) attribute values to be safely eval'd
$code = preg_replace('/\{\w+\}/', '', strtr($templ, array_map('addslashes', $attrvals)));
$fn = create_function('', "return ($code);");
if (!$fn) {
$res = false;
try {
$res = eval("return ($code);");
}
catch (ParseError $e) {
// ignore
}
if ($res === false) {
rcube::raise_error(array(
'code' => 505, 'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'code' => 505, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Expression parse error on: ($code)"), true, false);
continue;
}
$attrs[$lf] = $fn();
$attrs[$lf] = $res;
}
else {
// replace {attr} placeholders with concrete attribute values

Loading…
Cancel
Save