Steps to reproduce the problem:

1. create a new page with only a title
2. set the book option to create a new book
3. set the published option to not published
4. save the page
5. lookup the page in edit
6. result: page seems coupled to the first existing book in the list

Expected result:
a new book is created with the given title of the page as title of the book.

Instead the bookpage seems not coupled to a new book

Remark: the same result is gained when first publishing the page as a new book (this works as expected).
Subsequently change the bookpage to not-published and when doing edit after saving, the new book will have disappeared.

OS = FreeBsd (hosted webserver): FreeBSD wh-www13.xs4all.nl 4.10-RELEASE-p2 FreeBSD 4.10-RELEASE-p2 #0: Wed i386
webserver = Apache/1.3.37 (Unix) mod_ssl/2.8.28 OpenSSL/0.9.7d
PHP = PHP Version 5.2.6
Drupal = Drupal version 6.4

Comments

Flying Drupalist’s picture

Version: 6.4 » 6.9
Priority: Normal » Critical

This is a huge problem.

fab65’s picture

I have the same bug. The issue is due during creation of option default list (function book_get_books() in book.module l.256).
The query SQL return node with status = 1. But for node unpublish, status is equals to 0.
One solution is to replace :

line 267


if ($nids) {
      $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
      while ($link = db_fetch_array($result2)) {

by

global $user;
if ($nids) {
      $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND (n.status = 1 OR (n.status <> 1 AND n.uid = ".$user->uid.")) ORDER BY ml.weight, ml.link_title"));
      while ($link = db_fetch_array($result2)) {

Can you tell me if it's a good idea?

chawl’s picture

fab65 thank you very much, works great for dropdowns but "Add child page" and "book navigation" is missing.

By the way this, or a similar solution should, has to, must be committed.

It is really ridiculous to not to be able to create a book as a draft and publish at once.

How on earth our authors will send "a book" to editors for moderation?

Even reconstructing the original page order will be a pain.

Drupal is really shocking sometimes. Sigh.

jshprentz’s picture

Version: 6.9 » 6.12

I have the same problem in 6.12.

chawl’s picture

Version: 6.12 » 6.13

Intentionally bumped.

dazweeja’s picture

Same issue here. Create a new node, choose Create new book from Book outline fieldset, set node to unpublished, save node. At this point, the book table is fine. But there's no way to publish the node without breaking the book because if you edit the book, the dropdown in the Book outline will be set to the first book in the dropdown and the new book that was created won't exist in the dropdown menu. Bit of a showstopper for me as I need my pages to always be initially set to unpublished.

sven h’s picture

Have similar problems after upgrading from 5."low" to 6.16

Old books do not show hierarchy, new book lets itself be created (the first page allows to be top) but this new book does not appear in list of books, only the old book from before upgrade shows up in this list.

When editing the new first page it is shown as book but when editing older book pages the new book does not appear.

I have tried both published and unpublished pages, can't get it to work...

Oh, "add child page" appeared below book page after creating role "admin" and giving it permission to do all things book related. I found this necessary for more functions in drupal 6.

Edit:
After more digging it seems to work like this:
You need to have a role that has all book related permissions
All pages in the book need to be published

mr.andrey’s picture

Version: 6.13 » 6.16

subscribing... big problem, 6.16

JaredAM’s picture

Subscribe and possible solution: http://drupal.org/node/26552

JaredAM’s picture

Marvine’s picture

if you don't want to hack the core module, you can use hook_form_alter() in a module like :

if (!$form['book']['bid']['#options']['new'] 
    && $form['#node']->status == 0 
    && !$form['book']['plid']['#default_value']) {
	$form['book']['bid']['#options']['new'] = '<create a new book>';
	$form['book']['bid']['#default_value'] = 'new';			
}
mdupont’s picture

Priority: Critical » Normal
Status: Active » Closed (duplicate)