summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/book/book.module6
-rw-r--r--modules/book/book.test21
2 files changed, 25 insertions, 2 deletions
diff --git a/modules/book/book.module b/modules/book/book.module
index 64da2a5a9..38a10a84e 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -561,7 +561,7 @@ function book_update_bid($book_link) {
if ($mlids) {
db_update('book')
- ->fields(array('bid', $book_link['bid']))
+ ->fields(array('bid' => $book_link['bid']))
->condition('mlid', $mlids, 'IN')
->execute();
}
@@ -760,6 +760,10 @@ function book_nodeapi_presave($node) {
// Always save a revision for non-administrators.
if (!empty($node->book['bid']) && !user_access('administer nodes')) {
$node->revision = 1;
+ // The database schema requires a log message for every revision.
+ if (!isset($node->log)) {
+ $node->log = '';
+ }
}
// Make sure a new node gets a new menu link.
if (empty($node->nid)) {
diff --git a/modules/book/book.test b/modules/book/book.test
index 3dbfa4d0c..431301241 100644
--- a/modules/book/book.test
+++ b/modules/book/book.test
@@ -21,7 +21,7 @@ class BookTestCase extends DrupalWebTestCase {
*/
function testBook() {
// Create users.
- $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'add content to books'));
+ $book_author = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books'));
$web_user = $this->drupalCreateUser(array('access printer-friendly version'));
// Create new book.
@@ -57,6 +57,25 @@ class BookTestCase extends DrupalWebTestCase {
$this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3]);
$this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4]);
$this->checkBookNode($nodes[4], NULL, $nodes[3], $book, false);
+
+ $this->drupalLogout();
+
+ // Create a second book, and move an existing book page into it.
+ $this->drupalLogin($book_author);
+ $other_book = $this->createBookNode('new');
+ $node = $this->createBookNode($book->nid);
+ $edit = array('book[bid]' => $other_book->nid);
+ $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+
+ $this->drupalLogout();
+ $this->drupalLogin($web_user);
+
+ // Check that the nodes in the second book are displayed correctly.
+ // First we must set $this->book to the second book, so that the
+ // correct regex will be generated for testing the outline.
+ $this->book = $other_book;
+ $this->checkBookNode($other_book, array($node), false, false, $node);
+ $this->checkBookNode($node, NULL, $other_book, $other_book, false);
}
/**