Menu

#468 The each() function is deprecated in PHP 7.2+

3.5.5
open
nobody
PHP 7 (2)
5
2019-02-04
2019-02-04
Brian Kueck
No

The each() method is deprecated in PHP 7.2+

See: http://us1.php.net/manual/en/function.each.php
Replace each with a foreach loop from: http://php.net/manual/en/control-structures.foreach.php

Try to login to a database server without a user name or password & you'll see this error. Simply click the "Login" button, with 2 blank input values.

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in ...\phpPgAdmin\libraries\adodb\adodb-error.inc.php on line 106

Original Code:

L106: while (list($regexp,$code) = each($error_regexps)) {
L107:    if (preg_match($regexp, $errormsg)) {
L108:       return $code;
L109:    }
L110: }

Here is how to fix it. Simply edit L106.

L106: foreach ($error_regexps as $regexp => $code) {
L107:    if (preg_match($regexp, $errormsg)) {
L108:       return $code;
L109:    }
L110: }

Then it will correctly say, "Login failed".

See: http://php.net/manual/en/control-structures.foreach.php

If you search the code base for = each(, then you will find these identical matching problem lines of code:

  • classes\database\ADODB_base.php has 6 errors.
  • phpPgAdmin\dataexport.php has 1 error.
  • libraries\adodb\adodb-datadict.inc.php has 1 error.
  • libraries\adodb\adodb-error.inc.php has 2 errors (1 shown above).
  • libraries\adodb\adodb.inc.php has 1 error.
  • libraries\adodb\toexport.inc.php has 1 error.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB