PukiWiki
修訂 | 6ac4ecfdde6e5e5b1f0b85022c9c81b2c6a22c30 (tree) |
---|---|
時間 | 2016-01-08 03:47:44 |
作者 | ![]() |
Commiter | umorigu |
BugTrack2/369 Follow PHP7 changes of internal array pointer
Backward incompatible change of PHP7:
We already don't use current() function for array to calculate prev/next.
http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.foreach.array-pointer
http://wiki.php.net/rfc/php7_foreach
@@ -97,13 +97,19 @@ function plugin_navi_convert() | ||
97 | 97 | $pages = array_unique($pages); |
98 | 98 | natcasesort($pages); |
99 | 99 | if ($reverse) $pages = array_reverse($pages); |
100 | - | |
100 | + $pages = array_values($pages); | |
101 | 101 | $prev = $home; |
102 | - foreach ($pages as $page) { | |
103 | - if ($page === $current) break; | |
102 | + $next = ''; | |
103 | + foreach ($pages as $index=>$page) { | |
104 | + if ($page === $current) { | |
105 | + $next_key = $index + 1; | |
106 | + if (array_key_exists($next_key, $pages)) { | |
107 | + $next = $pages[$next_key]; | |
108 | + } | |
109 | + break; | |
110 | + } | |
104 | 111 | $prev = $page; |
105 | 112 | } |
106 | - $next = current($pages); | |
107 | 113 | |
108 | 114 | $pos = strrpos($current, '/'); |
109 | 115 | $up = ''; |