diff core/modules/book/src/BookOutline.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
line wrap: on
line diff
--- a/core/modules/book/src/BookOutline.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/core/modules/book/src/BookOutline.php	Mon Apr 23 09:46:53 2018 +0100
@@ -39,12 +39,14 @@
     if ($book_link['pid'] == 0) {
       return NULL;
     }
-    // Assigning the array to $flat resets the array pointer for use with each().
     $flat = $this->bookManager->bookTreeGetFlat($book_link);
+    reset($flat);
     $curr = NULL;
     do {
       $prev = $curr;
-      list($key, $curr) = each($flat);
+      $key = key($flat);
+      $curr = current($flat);
+      next($flat);
     } while ($key && $key != $book_link['nid']);
 
     if ($key == $book_link['nid']) {
@@ -78,10 +80,11 @@
    *   $book_link.
    */
   public function nextLink(array $book_link) {
-    // Assigning the array to $flat resets the array pointer for use with each().
     $flat = $this->bookManager->bookTreeGetFlat($book_link);
+    reset($flat);
     do {
-      list($key,) = each($flat);
+      $key = key($flat);
+      next($flat);
     } while ($key && $key != $book_link['nid']);
 
     if ($key == $book_link['nid']) {