diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 6f0ae24..03ff784 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -283,6 +283,31 @@ public function updateOutline(NodeInterface $node) { $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'); + + // Improve the usability of the error message by showing the changes that + // could not be applied. + if ($updated) { + $changes = []; + $new_parents = $this->loadBookLinks([$node->book['bid'], $node->book['pid']]); + if ($node->book['bid'] != $original['bid'] && $new_parents[$node->book['bid']]['access']) { + $changes[] = $this->t('The book was not changed to %book_label', ['%book_label' => $new_parents[$node->book['bid']]['title']]); + } + if ($node->book['pid'] != $original['pid'] && $new_parents[$node->book['pid']]['access']) { + $changes[] = $this->t('The parent was not changed to %parent_label', ['%parent_label' => $new_parents[$node->book['pid']]['title']]); + } + + $message = [ + [ + '#markup' => $this->t('The following changes were not applied:') + ], + [ + '#theme' => 'item_list', + '#items' => $changes, + ] + ]; + drupal_set_message($this->renderer->renderPlain($message), 'warning'); + } + return FALSE; }