diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 3e14c40..b5c4f3b 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -249,6 +249,12 @@ public function updateOutline(NodeInterface $node) { return FALSE; } + // Prevent changes to the book outline if the node being saved is not the + // default revision. + if ($node->isNewRevision() && !$node->isDefaultRevision()) { + return FALSE; + } + if (!empty($node->book['bid'])) { if ($node->book['bid'] == 'new') { // New nodes that are their own book. diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 66edec9..d81b370 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -749,4 +749,21 @@ public function testBookNavigationBlockOnUnpublishedBook() { $this->assertText($this->book->label(), 'Unpublished book with "Show block only on book pages" book navigation settings.'); } + /** + * Tests that forward revisions can not modify the book outline. + */ + public function testBookWithForwardRevisions() { + $this->drupalLogin($this->bookAuthor); + $this->book = $this->createBookNode('new'); + + /** @var \Drupal\book\BookManagerInterface $book_manager */ + $book_manager = $this->container->get('book.manager'); + + $this->book->setNewRevision(TRUE); + $this->book->isDefaultRevision(FALSE); + + $return = $book_manager->updateOutline($this->book); + $this->assertFalse($return, 'A forward revision can not change the book outline.'); + } + }