Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / book / src / BookOutline.php
index ec28d50c72012ffd40dc7cc224f5d92ec91d1e40..193c20f8fc64a86ab03762581dcacf77560599b2 100644 (file)
@@ -39,12 +39,14 @@ class BookOutline {
     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 @@ class BookOutline {
    *   $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']) {