diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 64f7128..330910e 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -914,33 +914,10 @@ public function bookTreeCheckAccess(&$tree, $node_links = array()) { // @todo This should be actually filtering on the desired node status // field language and just fall back to the default language. - $query = \Drupal::entityQuery('node'); - - $account = \Drupal::currentUser(); - if (!$account->hasPermission('bypass node access')) { - // If the user is able to view their own unpublished nodes, allow them - // to see these in addition to published nodes. Check that they actually - // have some unpublished nodes to view before adding the condition. - $access_query = \Drupal::entityQuery('node') - ->condition('uid', $account->id()) - ->condition('status', NODE_NOT_PUBLISHED); - if ($account->hasPermission('view own unpublished content') && ($own_unpublished = $access_query->execute())) { - $query->orConditionGroup() - ->condition('status', NODE_PUBLISHED) - ->condition('nid', $own_unpublished, 'IN'); - } - else { - // If not, restrict the query to published nodes. - $query->condition('status', NODE_PUBLISHED); - } - } - - $nids = $query - ->condition('nid', $nids, 'IN') - ->addTag('node_access') - ->execute(); + $book_links = $this->bookOutlineStorage->loadMultiple($nids); - foreach ($nids as $nid) { + foreach ($book_links as $book_link) { + $nid = $book_link['nid']; foreach ($node_links[$nid] as $mlid => $link) { $node_links[$nid][$mlid]['access'] = TRUE; }