Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.484
diff -u -r1.484 book.module
--- modules/book/book.module	20 Jan 2009 03:18:40 -0000	1.484
+++ modules/book/book.module	22 Jan 2009 17:27:07 -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();
 
@@ -528,6 +531,8 @@
           'bid' => $node->book['bid'],
         ))
         ->execute();
+      // Reset the cache of stored books.
+      book_get_books(TRUE);
     }
     else {
       if ($node->book['bid'] != db_query("SELECT bid FROM {book} WHERE nid = :nid", array(
@@ -821,6 +826,8 @@
     db_delete('book')
       ->condition('mlid', $node->book['mlid'])
       ->execute();
+    // Reset the cache of stored books.
+    book_get_books(TRUE);
   }
 }
 
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	22 Jan 2009 17:27:08 -0000
@@ -76,6 +76,18 @@
     $this->book = $other_book;
     $this->checkBookNode($other_book, array($node), false, false, $node);
     $this->checkBookNode($node, NULL, $other_book, $other_book, false);
+
+    // Check that modifying the list of available books properly updates the
+    // book list cache within the same request.
+    $this->drupalLogin($book_author);
+    $original_books = book_get_books();
+    $executed_book = $this->createBookDrupalExecute();
+    $updated_books = book_get_books();
+    $this->assertNotEqual($original_books, $updated_books, t("List of available books differ after creating a new book"));
+    book_nodeapi_delete($executed_book);
+    $updated_books = book_get_books();
+    $this->assertEqual($original_books, $updated_books, t("List of available books are the same after creating and deleting a book"));
+    $this->drupalLogout();
   }
 
   /**
@@ -171,6 +183,29 @@
 
     return $node;
   }
+
+  /**
+   * Create a book using drupal_execute().
+   *
+   * @return
+   *   The the node of the newly created book.
+   */
+  function createBookDrupalExecute() {
+    static $number = 0; // Used to ensure that when sorted nodes stay in same order.
+    // Create the book node.
+    $book_node = array('type' => 'article');
+    $form_state = array();
+    $form_state['values'] = array();
+    $form_state['values']['title'] = $number . ' - SimpleTest test node ' . $this->randomName(10);
+    $form_state['values']['body'] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
+    $form_state['values']['book'] = _book_link_defaults('new');
+    $form_state['values']['book']['bid'] = 'new';
+    $form_state['values']['op'] = t('Save');
+    drupal_execute($book_node['type'] . '_node_form', $form_state, (object)$book_node);
+    $book_node = node_load($form_state['nid']);
+
+    return $book_node;
+  }
 }
 
 class BookBlockTestCase extends DrupalWebTestCase {
