diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 41daf56..467a4e8 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -890,7 +890,6 @@ public function bookTreeCheckAccess(&$tree, $node_links = array()) { // language and just fall back to the default language. $nids = \Drupal::entityQuery('node') ->condition('nid', $nids, 'IN') - ->condition('status', 1) ->execute(); foreach ($nids as $nid) { diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php index dd7e373..50b2680 100644 --- a/core/modules/book/src/Tests/BookTest.php +++ b/core/modules/book/src/Tests/BookTest.php @@ -43,14 +43,14 @@ class BookTest extends WebTestBase { /** * A user with permission to view a book and access printer-friendly version. * - * @var object + * @var \Drupal\user\UserInterface */ protected $webUser; /** * A user with permission to create and edit books and to administer blocks. * - * @var object + * @var \Drupal\user\UserInterface */ protected $adminUser; @@ -80,6 +80,8 @@ protected function setUp() { /** * Creates a new book with a page hierarchy. + * + * @return \Drupal\node\NodeInterface[] */ function createBook() { // Create new book. @@ -684,7 +686,7 @@ public function testAdminBookListing() { */ public function testAdminBookNodeListing() { // Create a new book. - $this->createBook(); + $nodes = $this->createBook(); $this->drupalLogin($this->adminUser); // Load the book page list and assert the created book title is displayed @@ -694,6 +696,29 @@ public function testAdminBookNodeListing() { $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a'); $this->assertEqual((string) $elements[0], 'View', 'View link is found from the list.'); + $this->assertEqual(count($nodes), count($elements), 'All the book pages are displayed on the book outline page.'); + + // Unpublish a book in the hierarchy. + $nodes[0]->setPublished(FALSE); + $nodes[0]->save(); + + // Node should still appear on the outline for admins. + $this->drupalGet('admin/structure/book/' . $this->book->id()); + $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a'); + $this->assertEqual(count($nodes), count($elements), 'All the book pages are displayed on the book outline page.'); + + // Saving a book page not as the current version shouldn't effect the book. + $old_title = $nodes[1]->getTitle(); + $new_title = $this->randomGenerator->name(); + $nodes[1]->isDefaultRevision(FALSE); + $nodes[1]->setNewRevision(TRUE); + $nodes[1]->setTitle($new_title); + $nodes[1]->save(); + $this->drupalGet('admin/structure/book/' . $this->book->id()); + $elements = $this->xpath('//table//ul[@class="dropbutton"]/li/a'); + $this->assertEqual(count($nodes), count($elements), 'All the book pages are displayed on the book outline page.'); + $this->assertNoText($new_title, 'The revision that is not the default revision does not appear.'); + $this->assertText($old_title, 'The default revision title appears.'); } /**