Skip to content

Commit

Permalink
MDL-60281 forms: PHP7.2 deprecations in PEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Oct 16, 2017
1 parent 33683bc commit e3e3e0a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
13 changes: 8 additions & 5 deletions lib/pear/HTML/QuickForm/Rule/Compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ function _findOperator($name)
function validate($values, $operator = null)
{
$operator = $this->_findOperator($operator);
if ('==' != $operator && '!=' != $operator) {
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
$a = $values[0];
$b = $values[1];
if ($operator == '==') {
return $a == $b;
} else if ($operator == '!=') {
return $a != $b;
} else {
$compareFn = create_function('$a, $b', 'return $a ' . $operator . ' $b;');
// One of: <= , >= , < , > .
return eval('return ' . floatval($a) . $operator . floatval($b) . ';');
}

return $compareFn($values[0], $values[1]);
}


Expand Down
8 changes: 6 additions & 2 deletions lib/pear/HTML/QuickForm/date.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,18 @@ function _createElements()
$this->_options['maxYear'],
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1
);
array_walk($options, create_function('&$v,$k','$v = substr($v,-2);'));
array_walk($options, function(&$v, $k) {
$v = substr($v, -2);
});
break;
case 'h':
$options = $this->_createOptionList(1, 12);
break;
case 'g':
$options = $this->_createOptionList(1, 12);
array_walk($options, create_function('&$v,$k', '$v = intval($v);'));
array_walk($options, function(&$v, $k) {
$v = intval($v);
});
break;
case 'H':
$options = $this->_createOptionList(0, 23);
Expand Down
2 changes: 1 addition & 1 deletion lib/pear/PEAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ function _PEAR_call_destructors()
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
}

while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
foreach ($_PEAR_destructor_object_list as $k => $objref) {
$classname = get_class($objref);
while ($classname) {
$destructor = "_$classname";
Expand Down
7 changes: 5 additions & 2 deletions lib/pear/README_MOODLE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ MDL-52826 - Remove onsubmit events pointing to the global validation functions a
tag moved after the HTML
MDL-50484 - _getPersistantData() returns id with _persistant prefixed to element id.
MDL-55123 - corrected call to non-static functions in HTML_QuickForm to be PHP7.1-compliant
MDL-60281 - replaced deprecated create_function() with lambda functions for PHP7.2 compatibility


Pear
====
Changed constructors in classes PEAR and PEAR_ERROR to be __construct(). This has
been already changed upstream in 1.10.0, remove this line after upgrade.
It was decided that we will not upgrade this library from upstream any more, see MDL-52465

Changed constructors in classes PEAR and PEAR_ERROR to be __construct().
MDL-60281 - replaced deprecated function each() with foreach loop for PHP7.2 compatibility


Crypt/CHAP
Expand Down

0 comments on commit e3e3e0a

Please sign in to comment.