This seems too obvious, but the book module's outline is not restricted by allowed content types on the node/add form.
To reproduce:
1) Standard profile installation 8.2.7 and enable the Book module.
2) Go to /admin/structure/book/settings and select only the "Article" content type for "Content types allowed in book outlines".
3) Go to /node/add/page to create a new "Basic Page". Notice, the "Book Outline" fieldset is visible although you'd expect the settings in #2 to restrict the Basic Page content type.

CommentFileSizeAuthor
#49 2862291-nr-bot.txt1.49 KBneeds-review-queue-bot
#45 interdiff-2862291-43-45.txt2.83 KBLiam Morland
#45 drupal-book_outline-2862291-45.patch10.84 KBLiam Morland
#43 2862291-43.patch10.87 KBbalagan
#40 2862291-nr-bot.txt144 bytesneeds-review-queue-bot
#34 interdiff_32-34.txt531 bytesadityasingh
#34 2862291-34.patch9.9 KBadityasingh
#32 interdiff_29_32.txt4.7 KBanmolgoyal74
#32 2862291-32.patch9.91 KBanmolgoyal74
#30 2862291-after_patch.png42.48 KBAbhijith S
#30 2862291-before_patch.png136.97 KBAbhijith S
#29 2862291-29.patch9.68 KBMattDanger
#21 2862291-21.patch9.57 KBkevin.dutra
#12 Screen Shot 2017-04-12 at 11.40.48.png29.4 KBmr.baileys
#10 2862291-10.patch9.51 KBrakesh.gectcr
#10 interdiff-2862291-5-10.txt3.54 KBrakesh.gectcr
#5 book_outline_not-2862291-5.patch5.83 KBHaza
#4 dblog_warning.txt5.32 KBericpugh
#3 book_outline_not-limited-2862291-3.patch5.98 KBempesan

Issue fork drupal-2862291

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ericpugh created an issue. See original summary.

empesan’s picture

Assigned: Unassigned » empesan
Issue tags: +DevDaysSeville
empesan’s picture

Status: Active » Needs review
FileSize
5.98 KB

Reproduced issue and patch added.

ericpugh’s picture

FileSize
5.32 KB

I've tested this patch on Drupal 8.2.7 and it gets rid of the issue, however I'm seeing some (strange) errors in the dblog when creating content.
To reproduce:
1. Follow the steps in the original description, so that the "Article" content type is the only allowed content type in a book outline.
2. Create an article /node/add/article filling out only the Title and Body fields and adding to a book outline.
3. Errors in the dblog: /admin/reports/dblog

I'm not sure how the (attached) errors are related to this patch, but I did tested this on an identical clean install without the patch, and wasn't able to create the error.

Haza’s picture

Version: 8.2.7 » 8.4.x-dev
FileSize
5.83 KB

patch rerolled against 8.4.x

I didn't checked about the errors for now.

Status: Needs review » Needs work

The last submitted patch, 5: book_outline_not-2862291-5.patch, failed testing.

Haza’s picture

Status: Needs work » Needs review

Relaunched tests against 8.4.x

mathysp’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

I've tested the patch. Seems to work correctly on drupal v8.3. I do not see any errors in my dblog.

This patch will need tests though.

rakesh.gectcr’s picture

Assigned: empesan » rakesh.gectcr

Working on the test

rakesh.gectcr’s picture

Status: Needs work » Needs review
FileSize
3.54 KB
9.51 KB
rakesh.gectcr’s picture

Assigned: rakesh.gectcr » Unassigned
mr.baileys’s picture

This issue has been raised in the past (see for example #848470: _book_outline_access not restricting allowed types), and the fact that users with "Administer book outlines" permission can add all types to a book is noted on the book settings page:

So this is either a "Closed (works as designed)", or a Feature/Task instead of a bug.

mathysp’s picture

Category: Bug report » Feature request

I think it's worthy enough to consider this as a separate feature. Either way, this case is relevant; As of right now there is no good way to give a user role permission to only edit the book outlines, but still be limited to only the selected content-types.

I think there are two possible improvements that can be made:

1) Split up the permission so it is two-fold;
* Administer book outline:
* Can use all content-types in book outline

2) Add/enable an extra option so we can define wether or not admins can add all CT's or not.
* This can be a radio added to the structure/book/settings page

Meanwhile, we will use the patch from this issue.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jhedstrom’s picture

Issue tags: -Needs tests

I'm not sure how this would be considered a feature since sites should be able to disable content types from being in books. Ideally we could update the help text here and then add a change notice.

Also removing the needs tests tag as the latest patch has tests.

+++ b/core/modules/book/tests/src/Unit/BookManagerTest.php
@@ -114,4 +168,30 @@ public function providerTestGetBookParents() {
+   * Testing the Book Outline form element in node add page form.
+   * When the Book setting is enabled for the Content Type 'Page'.

Small nit here, the short description should be a single line.

borisson_’s picture

#16, the latest patch doesn't implement the correct behavior, see #12.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

u_tiwari’s picture

Why is this patch not merged to the core yet? This issue still exists as of Drupal version

8.6.11

Should we just use the patch for now? This is a legitimate use case where we want Book Outline form element to appear only for particular nodes and not all.

kevin.dutra’s picture

wturrell’s picture

I don't suppose anyone's already using a patch that applies cleanly to 8.7.x?

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

PCate’s picture

Patch needs a re-roll for Drupal 9.

PCate’s picture

Status: Needs review » Needs work
MattDanger’s picture

Status: Needs work » Needs review
FileSize
9.68 KB

Rerolled for 8.9.11

Abhijith S’s picture

Applied patch #29 on 8.9.x and it works fine.Adding screenshots

Before:
before

After:
after

But the patch can't be applied on 9.2.x,it is showing error

Hunk #1 succeeded at 203 (offset 26 lines).
Checking patch core/modules/book/tests/src/Unit/BookManagerTest.php...
error: while searching for:
   */
  protected $bookOutlineStorage;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
    $this->translation = $this->getStringTranslationStub();
    $this->configFactory = $this->getConfigFactoryStub([]);
    $this->bookOutlineStorage = $this->createMock('Drupal\book\BookOutlineStorageInterface');
    $this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface');
    $this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer);
  }


error: patch failed: core/modules/book/tests/src/Unit/BookManagerTest.php:54
error: core/modules/book/tests/src/Unit/BookManagerTest.php: patch does not apply

Abhijith S’s picture

Status: Needs review » Needs work
anmolgoyal74’s picture

Status: Needs work » Needs review
FileSize
9.91 KB
4.7 KB

Re-rolled for 9.2.x

Status: Needs review » Needs work

The last submitted patch, 32: 2862291-32.patch, failed testing. View results

adityasingh’s picture

Status: Needs work » Needs review
FileSize
9.9 KB
531 bytes

Fixed test case. Please review the patch.

tstoeckler’s picture

Unfortunately I don't think this issue can be committed, as allowing other node types is considered a feature. See #502430: Allow the book outline functionality on non-book-enabled node types to be hidden from users with the "Administer book outlines" permission for more information on that and on a possible solution that will still allow people to fix this on their systems while keeping the existing feature for whoever needs it.

I think this should be closed (either as "won't fix" or as a duplicate of the linked issue) but will let someone who has worked on this make the call.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed

This extension is being deprecated, see #3376070: [Meta] Tasks to deprecate Book module. It will be removed from core and moved to a contrib project, #3376101: [11.x] [Meta] Tasks to remove Book.

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

This issue may be re-opened if it can be considered critical, If unsure, re-open the issue and ask in a comment.

balagan’s picture

balagan’s picture

Also, in the book.module file book_form_node_form_alter() function the 'Change book (update list of parents)' submit button is placed in the forms, if user has 'administer book outlines' permission, disregarding the allowed node type.
After further thinking, with 'add content to book' permission the allowed node type is checked, so probably this is intentional.

Liam Morland’s picture

This is patch #43 with the issues from the automated tests fixed.

There doesn't appear to be any progress towards moving the book module to contrib.

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

Liam Morland’s picture

I created an issue fork with patch 45 plus an additional fix. It has not displayed the button to make a merge request.

Liam Morland’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
1.49 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

ankithashetty made their first commit to this issue’s fork.

ankithashetty’s picture

Status: Needs work » Needs review

Opened an MR for the changes made in #47, thanks!

poker10’s picture

Status: Needs review » Postponed

I do not think we could easily change this for reasons mentioned in #35 and #12. Changing this will break existing sites already using this feature. So if we want to do this, we should think about existing sites and BC.

On the other hand, I do not think this issue is critical enough, so I suppose it should remain as Postponed, see #42. I see some progress in child issues here: #3376070: [Meta] Tasks to deprecate Book module. Thanks!