From: <var...@us...> - 2020-03-23 13:03:26
|
Revision: 10157 http://sourceforge.net/p/phpwiki/code/10157 Author: vargenau Date: 2020-03-23 13:03:24 +0000 (Mon, 23 Mar 2020) Log Message: ----------- replace deprecated "each" -- patches by Christof Meerwald Modified Paths: -------------- trunk/lib/ExternalReferrer.php trunk/lib/PageList.php trunk/lib/WikiPluginCached.php trunk/lib/WikiUser.php trunk/lib/difflib.php trunk/lib/mimelib.php trunk/lib/pear/Cache/Container/file.php trunk/lib/pear/DB/storage.php trunk/lib/pear/PEAR.php trunk/lib/plugin/PhotoAlbum.php trunk/lib/plugin/SiteMap.php trunk/lib/plugin/TexToPng.php trunk/lib/plugin/VisualWiki.php trunk/lib/plugin/WikiAdminSetAcl.php trunk/lib/stdlib.php trunk/lib/wikilens/PageListColumns.php trunk/themes/blog/jscalendar/calendar.php Modified: trunk/lib/ExternalReferrer.php =================================================================== --- trunk/lib/ExternalReferrer.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/ExternalReferrer.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -109,7 +109,7 @@ } $url = strtolower($url); $ref = $url; - while (list($key, $var) = @each($this->searchEngines)) { + foreach ($this->searchEngines as $key => $var) { if (strstr($ref, $key)) { unset($ref); $ref["engine"] = $var["engine"]; Modified: trunk/lib/PageList.php =================================================================== --- trunk/lib/PageList.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/PageList.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -1911,7 +1911,7 @@ function addPageList($array) { - while (list($pagename, $selected) = each($array)) { + foreach ($array as $pagename => $selected) { if ($selected) $this->addPageSelected((string)$pagename); $this->addPage((string)$pagename); } @@ -1940,7 +1940,7 @@ function addPageList($array) { - while (list($pagename, $selected) = each($array)) { + foreach ($array as $pagename => $selected) { if ($selected) $this->addPageSelected((string)$pagename); $this->addPage((string)$pagename); } Modified: trunk/lib/WikiPluginCached.php =================================================================== --- trunk/lib/WikiPluginCached.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/WikiPluginCached.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -607,7 +607,7 @@ { if (!empty($argarray)) { $argstr = ''; - while (list($key, $value) = each($argarray)) { + foreach ($argarray as $key => $value) { $argstr .= $key . '=' . '"' . $value . '" '; // FIXME: How are values quoted? Can a value contain '"'? // TODO: rawurlencode(value) Modified: trunk/lib/WikiUser.php =================================================================== --- trunk/lib/WikiUser.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/WikiUser.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -2233,7 +2233,8 @@ // fix old-style prefs } elseif (is_numeric($name) and is_array($packed_pref)) { if (count($packed_pref) == 1) { - list($name, $value) = each($packed_pref); + $name = key($packed_pref); + $value = current($packed_pref); $prefs[$name] = $value; } } else { Modified: trunk/lib/difflib.php =================================================================== --- trunk/lib/difflib.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/difflib.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -286,7 +286,7 @@ continue; $matches = $ymatches[$line]; reset($matches); - while (list ($junk, $y) = each($matches)) + foreach ($matches as $junk => $y) if (empty($this->in_seq[$y])) { $k = $this->lcs_pos($y); assert($k > 0); @@ -293,7 +293,7 @@ $ymids[$k] = $ymids[$k - 1]; break; } - while (list ($junk, $y) = each($matches)) { + foreach ($matches as $junk => $y) { if ($y > $this->seq[$k - 1]) { assert($y < $this->seq[$k]); // Optimization: this is a common case: Modified: trunk/lib/mimelib.php =================================================================== --- trunk/lib/mimelib.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/mimelib.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -72,7 +72,7 @@ { $header = "Content-Type: $type/$subtype"; reset($params); - while (list($key, $val) = each($params)) { + foreach ($params as $key => $val) { //FIXME: what about non-ascii printables in $val? if (!preg_match('/^' . MIME_TOKEN_REGEXP . '$/', $val)) $val = '"' . addslashes($val) . '"'; @@ -276,7 +276,7 @@ { $footnotes = array(); reset($params); - while (list($p, $reference) = each($params)) { + foreach ($params as $p => $reference) { if (preg_match('/^ref([1-9][0-9]*)$/', $p, $m)) $footnotes[$m[1]] = sprintf(_("[%d] See [%s]"), $m[1], rawurldecode($reference)); Modified: trunk/lib/pear/Cache/Container/file.php =================================================================== --- trunk/lib/pear/Cache/Container/file.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/pear/Cache/Container/file.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -275,7 +275,8 @@ krsort($this->entries); reset($this->entries); - while ($this->total_size > $this->lowwater && list($lastmod, $entry) = each($this->entries)) { + foreach ($this->entries as $lastmod => $entry) { + if ($this->total_size <= $this->lowwater) break; if (@unlink($entry['file'])) { $this->total_size -= $entry['size']; } else { Modified: trunk/lib/pear/DB/storage.php =================================================================== --- trunk/lib/pear/DB/storage.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/pear/DB/storage.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -336,7 +336,7 @@ } reset($rowdata); $found_keycolumn = false; - while (list($key, $value) = each($rowdata)) { + foreach ($rowdata as $key => $value) { if ($key == $this->_keycolumn) { $found_keycolumn = true; } Modified: trunk/lib/pear/PEAR.php =================================================================== --- trunk/lib/pear/PEAR.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/pear/PEAR.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -782,7 +782,7 @@ $_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"; Modified: trunk/lib/plugin/PhotoAlbum.php =================================================================== --- trunk/lib/plugin/PhotoAlbum.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/plugin/PhotoAlbum.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -220,7 +220,7 @@ $cell_width = 0; $numcols = count($photos); $keep = $photos; - while (list($key, $value) = each($photos)) { + foreach ($photos as $key => $value) { list($x, $y, $s, $t) = @getimagesize($value['src']); if ($height != 'auto') $y = $this->newSize($y, $height); if ($width != 'auto') $y = round($y * $this->newSize($x, $width) / $x); @@ -251,7 +251,7 @@ } display_slides();")); - while (list($key, $value) = each($photos)) { + foreach ($photos as $key => $value) { if ($p && basename($value["name"]) != "$p") { continue; } @@ -654,7 +654,7 @@ } elseif ($web_location == 1) { //TODO: check if the file is an image $contents = preg_split('/\n/', $contents); - while (list($key, $value) = each($contents)) { + foreach ($contents as $key => $value) { $data = preg_split('/\;/', $value); if (count($data) == 0 || empty($data[0]) || preg_match('/^#/', $data[0]) Modified: trunk/lib/plugin/SiteMap.php =================================================================== --- trunk/lib/plugin/SiteMap.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/plugin/SiteMap.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -205,7 +205,7 @@ $nothing = ''; } - while (list($key, $link) = each($pagearr)) { + foreach ($pagearr as $key => $link) { if (!empty($includepages)) { $a = substr_count($key, '*'); $indenter = str_pad($nothing, $a); Modified: trunk/lib/plugin/TexToPng.php =================================================================== --- trunk/lib/plugin/TexToPng.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/plugin/TexToPng.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -226,7 +226,7 @@ $this->dbg('Error during execution of ' . $cmd); } ; - while (list($key, $value) = each($errortxt)) { + foreach ($errortxt as $key => $value) { if ($complainvisibly) { $this->complain($value . "\n"); } else { Modified: trunk/lib/plugin/VisualWiki.php =================================================================== --- trunk/lib/plugin/VisualWiki.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/plugin/VisualWiki.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -381,10 +381,10 @@ // remove dead links and collect links reset($pages); - while (list($name, $page) = each($pages)) { + foreach ($pages as $name => $page) { if (is_array($page['backlinks'])) { reset($page['backlinks']); - while (list($index, $link) = each($page['backlinks'])) { + foreach ($page['backlinks'] as $index => $link) { if (!isset($pages[$link]) || $link == $name) { unset($pages[$name]['backlinks'][$index]); } else { Modified: trunk/lib/plugin/WikiAdminSetAcl.php =================================================================== --- trunk/lib/plugin/WikiAdminSetAcl.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/plugin/WikiAdminSetAcl.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -76,7 +76,7 @@ if (isset($acl['_del_group'])) { //del groups with perm foreach ($acl['_del_group'] as $access => $del) { - while (list($group, $dummy) = each($del)) + foreach ($del as $group => $dummy) unset($acl[$access][$group]); } unset($acl['_del_group']); Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/stdlib.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -714,7 +714,7 @@ // FIXME: use the arg-separator which might not be & $split_args = explode('&', $query_args); $args = array(); - while (list($key, $val) = each($split_args)) + foreach ($split_args as $key => $val) if (preg_match('/^ ([^=]+) =? (.*) /x', $val, $m)) $args[$m[1]] = $m[2]; return $args; Modified: trunk/lib/wikilens/PageListColumns.php =================================================================== --- trunk/lib/wikilens/PageListColumns.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/lib/wikilens/PageListColumns.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -376,8 +376,8 @@ $numToShow = count($recs); } $html = HTML(); - while ((list($key, $val) = each($recs)) && $counter < $numToShow) { - if ($val < 3) { + foreach ($recs as $key => $val) { + if (($counter >= $numToShow) || ($val < 3)) { break; } if ($counter > 0) { Modified: trunk/themes/blog/jscalendar/calendar.php =================================================================== --- trunk/themes/blog/jscalendar/calendar.php 2020-03-23 12:01:44 UTC (rev 10156) +++ trunk/themes/blog/jscalendar/calendar.php 2020-03-23 13:03:24 UTC (rev 10157) @@ -95,7 +95,7 @@ function _make_js_hash($array) { $jstr = ''; reset($array); - while (list($key, $val) = each($array)) { + foreach ($array as $key => $value) { if (is_bool($val)) $val = $val ? 'true' : 'false'; else if (!is_numeric($val)) @@ -109,7 +109,7 @@ function _make_html_attr($array) { $attrstr = ''; reset($array); - while (list($key, $val) = each($array)) { + foreach ($array as $key => $value) { $attrstr .= $key . '="' . $val . '" '; } return $attrstr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |