Download & Extend

Working on unpublished books messes up book hierarchy of other book

Project:Drupal core
Version:8.x-dev
Component:book.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)
Issue tags:needs backport to D7

Issue Summary

If you unpublish a book and then update the unpublished first book page the hierarchy of the very first book in the system will mess up:

  • The unpublished book and the subpages become members of the very first book (though you won't see this page and the subpages in the book hierarchy on /admin/content/book/... <7li>
  • if you remove the former book from the very first book, all subpages become direct subpages of the very first book. You have to manually remove these pages from that book

This is not a duplicate of #26552: Allow users with administer nodes perm. to create unpublished books. or #353125: Unpublishing book parent breaks book hierarchy because this is a really annoying bug!

Comments

#1

Status:active» needs work

Hi
I too facing same problem. Currently i am using Drupal version 7.15, Once i unpublished book and the subpages become members of the very first book and also book hierarchy also changed. I tested in drupal 8.x-dev, but same issue created. Please check this issue

With regards
tssarun

#2

Status:needs work» active

You'd put "need work" if a patch needed work. Since there is no patch it should stay "active".

#3

Version:7.14» 8.x-dev
Priority:normal» major

Based on the report, should be major.

#4

We still need to confirm whether this is a duplicate of #26552: Allow users with administer nodes perm. to create unpublished books.. Thanks @nod_ and @tssarun!

#5

Version:8.x-dev» 7.15

I'm not entirely certain if this issue is identical to #26552, but fixing #26552 should also solve this issue.

This issue (#1688026) specifically refers to top level nodes in a book outline that are unpublished. When the top level node is unpublished, it disappears from the book outline menu, but the usual first menu item on the book outline menu "create new book" is not displayed so when you make any edits to the the top level book node, it gets reassigned against the first book that appears after the "create new book" selection option on the Node Edit form. From this point, the original book item is gone even if you republish the top level book node. The top level node, which was previously a book of its own is now a child node and all of its children are also adopted into the new top level book node parent. If you look at the book table in the database, everything under that book ID is now missing.

At this point, your original hierarchy appears to be irreversibly wrecked, but so long as you don't make any edits to any of your original child nodes, all you need to do to get Drupal back to normal is to republish your original top level node while at the same time selecting "create new book" in the Book outline at the same time. Now, I just said that "create new book" is not an option anymore, but it reappears once your node is assigned against a parent after your first edit. Once you save your node as a new book, it then gets re-created as a top level book node and once it becomes a top level node again, it carries all of its child relationships out from under the incorrect parent. I know this sounds confusing so I'm going to show some steps to reproduce this at the end of this entry.

This will only work if you don't make any edits to the child nodes underneath your original top level node while it's unpublished. Doing so will cause your child nodes to get reassigned against another top level node. If there are no other top level nodes, then the node you're editing will become a top level node itself when you edit it.

The hack to the book module suggested in #26552 works for D7 as well as for D8. In D7, if you comment out one database condition, the unpublished book node does not disappear from the book outline menu from the node edit form and so the relationships aren't broken when you save the form.

In D7, the condition to comment out is located around line 393

      $query->condition('n.status', 1);

Steps to Reproduce

  1. On a fresh system, create a book page named "Book A" and make it a new book.
  2. Add one child page named "Child A" to the Book A hierarchy.
  3. Create a book page named "Book B" and make it a new book.
  4. Add one child page named "Child B" to the Book B hierarchy.
  5. Unpublish Book B.
  6. Edit Book B and save it, but before you hit the save button, look at the Book Outline options and notice that "Book A" is your only available option.
  7. Republish Book B. Both Book B and Child B now belong to Book A.
  8. Unpublish Book B.
  9. Edit Book B. Go to the Book Outline and choose "create new book".
  10. Make sure "published" is checked in the publish options.
  11. Save Book B.

The original Book B hierarchy should be restored now and Child B is back under Book B.

#6

Hi hyperlinked,

I too i agree with you. I too checked by comment the following line in $query->condition('n.status', 1) inside book_get_books(). Now its working fine. Or we need to add 'create new book' or 'Please select' in the drop down menu. If we do this then no need to comment the following condition $query->condition('n.status', 1).

Thanks @hyperlinked and @xjm

With regards
tssarun

#7

Version:7.15» 8.x-dev

Restoring version.

#8

Hi xjm

I too feel this is related(duplicate) Allow users with administer nodes perm. to create unpublished books. and i created patch for drupal 8 with solves both the issues(1688026,26552). Please check and review it

Thanks Xjm, hyperlinked and nod_

#9

Status:active» closed (duplicate)

Hi

This issue is related to Allow users with administer nodes perm. to create unpublished books. , so i feel this issue duplicate.....

regards
tssarun

#10

Version:8.x-dev» 7.16

#26552: Allow users with administer nodes perm. to create unpublished books. is related but not a duplicate.

#11

Status:closed (duplicate)» active

#12

Version:7.16» 8.x-dev

restoring version

#13

Priority:major» normal
Status:active» closed (duplicate)

This issue is a duplicate because the other issue resolves this one as well. Please see #26552: Allow users with administer nodes perm. to create unpublished books..

nobody click here