diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php
index fba85ad..6f0ae24 100644
--- a/core/modules/book/src/BookManager.php
+++ b/core/modules/book/src/BookManager.php
@@ -249,15 +249,6 @@ public function updateOutline(NodeInterface $node) {
return FALSE;
}
- // Prevent changes to the book outline if the node being saved is not the
- // default revision.
- // @todo Convert this to an entity constraint in
- // https://www.drupal.org/node/2883868.
- if (!$node->isDefaultRevision()) {
- drupal_set_message($this->t('This is not the default revision. You can only change the book outline for the published version of this content.'), 'error');
- return FALSE;
- }
-
if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') {
// New nodes that are their own book.
@@ -284,6 +275,17 @@ public function updateOutline(NodeInterface $node) {
// handle it here if it did not.
$node->book['pid'] = $node->book['bid'];
}
+
+ // Prevent changes to the book outline if the node being saved is not the
+ // default revision.
+ // @todo Convert this to an entity constraint in
+ // https://www.drupal.org/node/2883868.
+ $updated = !$new && (($original = $this->loadBookLink($node->id(), FALSE)) && ($node->book['bid'] != $original['bid'] || $node->book['pid'] != $original['pid']));
+ if (($new || $updated) && !$node->isDefaultRevision()) {
+ drupal_set_message($this->t('This is not the default revision. You can only change the book outline for the published version of this content.'), 'error');
+ return FALSE;
+ }
+
return $this->saveBookLink($node->book, $new);
}
diff --git a/core/modules/book/tests/src/Functional/BookContentModerationTest.php b/core/modules/book/tests/src/Functional/BookContentModerationTest.php
index 3a372a9..24e3d15 100644
--- a/core/modules/book/tests/src/Functional/BookContentModerationTest.php
+++ b/core/modules/book/tests/src/Functional/BookContentModerationTest.php
@@ -78,6 +78,11 @@ public function testBookWithForwardRevisions() {
$this->checkBookNode($book_1, [$book_1_nodes[0], $book_1_nodes[3], $book_1_nodes[4]], FALSE, FALSE, $book_1_nodes[0], []);
$this->checkBookNode($book_1_nodes[0], [$book_1_nodes[1], $book_1_nodes[2]], $book_1, $book_1, $book_1_nodes[1], [$book_1]);
+ // Save a new draft revision for the node without any changes and check that
+ // the error message is not displayed.
+ $this->drupalPostForm('node/' . $book_1_nodes[1]->id() . '/edit', [], t('Save and Create New Draft'));
+
+ $this->assertSession()->pageTextNotContains('This is not the default revision. You can only change the book outline for the published version of this content.');
}
}