Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.483
diff -u -r1.483 book.module
--- modules/book/book.module	29 Dec 2008 16:03:56 -0000	1.483
+++ modules/book/book.module	18 Jan 2009 00:21:03 -0000
@@ -292,11 +292,14 @@
  *
  * This list may be used for generating a list of all the books, or for building
  * the options for a form select.
+ *
+ * @param $reset
+ *   Reset the cache of stored books.
  */
-function book_get_books() {
+function book_get_books($reset = FALSE) {
   static $all_books;
 
-  if (!isset($all_books)) {
+  if ($reset || !isset($all_books)) {
     $all_books = array();
     $nids = db_query("SELECT DISTINCT(bid) FROM {book}")->fetchCol();
 
Index: modules/book/book.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.test,v
retrieving revision 1.7
diff -u -r1.7 book.test
--- modules/book/book.test	23 Dec 2008 14:32:08 -0000	1.7
+++ modules/book/book.test	18 Jan 2009 00:21:04 -0000
@@ -76,6 +76,15 @@
     $this->book = $other_book;
     $this->checkBookNode($other_book, array($node), false, false, $node);
     $this->checkBookNode($node, NULL, $other_book, $other_book, false);
+
+    // Check that multiple nodes inserted in the same request work as expected.
+    // This typically occurs when inserting multiple nodes with
+    // drupal_execute().
+    $this->drupalLogin($book_author);
+    $nodes = $this->createBookOutline();
+    $this->checkBookNode($nodes[0], $nodes);
+    $this->checkBookNode($nodes[1], NULL);
+    $this->drupalLogout();
   }
 
   /**
@@ -171,6 +180,42 @@
 
     return $node;
   }
+
+  /**
+   * Create a book outline using drupal_execute()
+   *
+   * @return
+   *   The array of nodes created.
+   */
+  function createBookOutline() {
+    static $number = 0; // Used to ensure that when sorted nodes stay in same order.
+    // Create the book node.
+    $parent_node = array();
+    $parent_node['values'] = array();
+    $parent_node['values']['type'] = 'article';
+    $parent_node['values']['title'] = $number . ' - SimpleTest test node ' . $this->randomName(10);
+    $parent_node['values']['body'] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
+    $parent_node['values']['book'] = _book_link_defaults('new');
+    $parent_node['values']['book']['bid'] = 'new';
+    $parent_node['values']['op'] = t('Save');
+    drupal_execute($parent_node['values']['type'] . '_node_form', $parent_node, (object)$parent_node['values']);
+    $book_id = $parent_node['nid'];
+    $parent_node = node_load($book_id);
+
+    // Create the child node of the book node.
+    $node = array();
+    $node['values'] = array();
+    $node['values']['type'] = 'article';
+    $node['values']['title'] = $number . ' - SimpleTest test node ' . $this->randomName(10);
+    $node['values']['body'] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
+    $node['values']['book']['bid'] = $book_id;
+    $node['values']['book']['plid'] = $parent_node->book['mlid'];
+    $node['values']['op'] = t('Save');
+    drupal_execute($node['values']['type'] . '_node_form', $node, (object)$node['values']);
+    $node = node_load($node['nid']);
+
+    return array($parent_node, $node);
+  }
 }
 
 class BookBlockTestCase extends DrupalWebTestCase {
