MDL-58546 libraries: Patch ADOdb for PHP 7.2 compat

This commit is contained in:
Marina Glancy 2017-10-03 15:52:18 +08:00
parent 3fede79302
commit acfb9df1a8
8 changed files with 12 additions and 11 deletions

View File

@ -520,7 +520,7 @@ class ADODB_DataDict {
list($lines,$pkey,$idxs) = $this->_GenFields($flds);
// genfields can return FALSE at times
if ($lines == null) $lines = array();
list(,$first) = each($lines);
$first = current($lines);
list(,$column_def) = preg_split("/[\t ]+/",$first,2);
}
return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));

View File

@ -111,7 +111,7 @@ function adodb_error_pg($errormsg)
'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
);
reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) {
foreach ($error_regexps as $regexp => $code) {
if (preg_match("/$regexp/mi", $errormsg)) {
return $code;
}

View File

@ -1164,8 +1164,7 @@ if (!defined('_ADODB_LAYER')) {
foreach($inputarr as $arr) {
$sql = ''; $i = 0;
//Use each() instead of foreach to reduce memory usage -mikefedyk
while(list(, $v) = each($arr)) {
foreach ($arr as $v) {
$sql .= $sqlarr[$i];
// from Ron Baldwin <ron.baldwin#sourceprose.com>
// Only quote string types

View File

@ -225,7 +225,7 @@ class ADODB_ado extends ADOConnection {
// Map by http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthcreateparam.asp
// Check issue http://bugs.php.net/bug.php?id=40664 !!!
while(list(, $val) = each($inputarr)) {
foreach ($inputarr as $val) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')

View File

@ -248,7 +248,7 @@ class ADODB_ado extends ADOConnection {
$oCmd->CommandText = $sql;
$oCmd->CommandType = 1;
while(list(, $val) = each($inputarr)) {
foreach ($inputarr as $val) {
$type = gettype($val);
$len=strlen($val);
if ($type == 'boolean')

View File

@ -209,7 +209,7 @@ class ADODB_text extends ADOConnection {
$where_arr = array();
reset($this->_origarray);
while (list($k_arr,$arr) = each($this->_origarray)) {
foreach ($this->_origarray as $arr) {
if ($i == 0 && $this->_skiprow1)
$where_arr[] = $arr;
@ -247,7 +247,7 @@ class ADODB_text extends ADOConnection {
$i = 0;
$n = '';
reset($this->_colnames);
while (list($k_n,$n) = each($this->_colnames)) {
foreach ($this->_colnames as $n) {
if ($col == strtoupper(trim($n))) break;
$i += 1;
@ -302,7 +302,7 @@ class ADODB_text extends ADOConnection {
if ($at == 0) {
$i = 0;
reset($projnames);
while (list($k_n,$n) = each($projnames)) {
foreach ($projnames as $n) {
if (strtoupper(trim($n)) == $col) {
$at = $i+1;
break;

View File

@ -30,5 +30,7 @@ Our changes:
* Removed random seed initialization from lib/adodb/adodb.inc.php:216 (see 038f546 and MDL-41198).
* MDL-52286 Added muting erros in ADORecordSet::__destruct().
Check if fixed upstream during the next upgrade and remove this note. (8638b3f1441d4b928)
* MDL-58546 replaced each() with foreach for PHP 7.2 compatibility.
pull request upstream: https://github.com/ADOdb/ADOdb/pull/373
skodak, iarenaza, moodler, stronk7, abgreeve, lameze, ankitagarwal
skodak, iarenaza, moodler, stronk7, abgreeve, lameze, ankitagarwal, marinaglancy

View File

@ -77,7 +77,7 @@ function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote =
reset($fieldTypes);
$i = 0;
$elements = array();
while(list(,$o) = each($fieldTypes)) {
foreach ($fieldTypes as $o) {
$v = ($o) ? $o->name : 'Field'.($i++);
if ($escquote) $v = str_replace($quote,$escquotequote,$v);