? boost-624026.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.230
diff -u -p -r1.3.2.2.2.5.2.230 boost.module
--- boost.module	6 Nov 2009 10:41:41 -0000	1.3.2.2.2.5.2.230
+++ boost.module	6 Nov 2009 11:31:55 -0000
@@ -430,11 +430,28 @@ function boost_comment($comment, $op) {
 }
 
 /**
+ * Sets the base_dir array key based on settings.
+ *
+ * @param array &$data
+ *  array that might want to have the base_dir key added to it.
+ */
+function boost_set_base_dir_in_array(&$data) {
+  if ($data && !BOOST_FLUSH_ALL_MULTISITE) {
+    foreach ($data as $key => $value) {
+      if (!array_key_exists(['base_dir'], $data[$key])) {
+        $data[$key]['base_dir'] = BOOST_FILE_PATH;
+      }
+    }
+  }
+}
+
+/**
  * Implementation of hook_nodeapi(). Acts on nodes defined by other modules.
  */
 function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   if (!BOOST_ENABLED) return;
-  $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $node->nid);
+  $data[] = array('page_callback' => 'node', 'page_id' => $node->nid);
+  boost_set_base_dir_in_array($data);
 
   switch ($op) {
     case 'insert':
@@ -550,7 +567,7 @@ function boost_expire_node($node, $nid =
     $paths['node'] = 'node/' . $node->nid;
   }
   else {
-    $data['node'] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $node->nid);
+    $data['node'] = array('page_callback' => 'node', 'page_id' => $node->nid);
   }
 
   // If promoted to front page, expire front page
@@ -568,7 +585,7 @@ function boost_expire_node($node, $nid =
           $paths['term' . $tid] = 'taxonomy/term/' . $tid;
         }
         else {
-          $data['term' . $tid] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'taxonomy', 'page_id' => $tid);
+          $data['term' . $tid] = array('page_callback' => 'taxonomy', 'page_id' => $tid);
         }
       }
     }
@@ -610,7 +627,7 @@ function boost_expire_node($node, $nid =
             $paths['reference' . $nid] = 'node/' . $nid;
           }
           else {
-            $data['reference' . $nid] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $nid);
+            $data['reference' . $nid] = array('page_callback' => 'node', 'page_id' => $nid);
           }
         }
       }
@@ -625,7 +642,7 @@ function boost_expire_node($node, $nid =
             $paths['referrer' . $nid['nid']] = 'node/' . $nid['nid'];
           }
           else {
-            $data['referrer' . $nid['nid']] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $nid['nid']);
+            $data['referrer' . $nid['nid']] = array('page_callback' => 'node', 'page_id' => $nid['nid']);
           }
         }
       }
@@ -637,7 +654,8 @@ function boost_expire_node($node, $nid =
     $GLOBALS['_boost_router_item'] = isset($GLOBALS['_boost_router_item']) ? $GLOBALS['_boost_router_item'] : _boost_get_menu_router();
     $router_item = $GLOBALS['_boost_router_item'];
     $relationship = array();
-    $relationship[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => $router_item['page_callback'], 'page_type' => $router_item['page_type'], 'page_id' => $router_item['page_id']);
+    $relationship[] = array('page_callback' => $router_item['page_callback'], 'page_type' => $router_item['page_type'], 'page_id' => $router_item['page_id']);
+    boost_set_base_dir_in_array($data);
     $data = array_merge($data, boost_cache_get_node_relationships($relationship));
   }
 
@@ -780,7 +798,8 @@ function boost_user($op, &$edit, &$accou
           $flushed = boost_cache_expire_derivative($paths, TRUE, TRUE);
         }
         else {
-          $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'user', 'page_id' => $account->uid);
+          $data[] = array('page_callback' => 'user', 'page_id' => $account->uid);
+          boost_set_base_dir_in_array($data);
           $flushed = boost_cache_expire_router($data, TRUE, TRUE);
         }
         if (BOOST_VERBOSE >= 7) {
@@ -950,11 +969,12 @@ function boost_block_form_flush_submit(&
   $data = array();
   // Special front page handling
   if ($form['values']['page_callback'] == 'node_page_default' && BOOST_CACHE_XML) {
-    $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node_feed');
+    $data[] = array('page_callback' => 'node_feed');
   }
-  $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => $form['values']['page_callback'], 'page_type' => $form['values']['page_type'], 'page_id' => $form['values']['page_id']);
+  $data[] = array('page_callback' => $form['values']['page_callback'], 'page_type' => $form['values']['page_type'], 'page_id' => $form['values']['page_id']);
   $flushed = 0;
   if ($data) {
+    boost_set_base_dir_in_array($data);
     $flushed += boost_cache_expire_router($data, TRUE);
   }
   if (array_key_exists('path', $form['values'])) {
@@ -1454,7 +1474,12 @@ function boost_cache_expire_all_filesyst
  * Resets all entries in database.
  */
 function boost_cache_clear_all_db() {
-  db_query("UPDATE {boost_cache} SET expire = %d WHERE base_dir = '%s'", 0, BOOST_FILE_PATH);
+  if (BOOST_FLUSH_ALL_MULTISITE) {
+    db_query("UPDATE {boost_cache} SET expire = %d", 0);
+  }
+  else {
+    db_query("UPDATE {boost_cache} SET expire = %d WHERE base_dir = '%s'", 0, BOOST_FILE_PATH);
+  }
 }
 
 /**
@@ -2124,10 +2149,17 @@ function boost_cache_get_node_relationsh
     if (!isset($data['page_callback']) || !isset($data['page_type']) || !isset($data['page_id'])) {
       continue;
     }
-    $data['base_dir'] = isset($data['base_dir']) ? $data['base_dir'] : BOOST_FILE_PATH;
-    $result = db_query("SELECT page_callback, page_type, page_id FROM {boost_cache_relationships} WHERE child_page_id = '%s' AND child_page_type = '%s' AND child_page_callback = '%s' AND base_dir = '%s'", $data['page_id'], $data['page_type'], $data['page_callback'], $data['base_dir']);
+
+    if (BOOST_FLUSH_ALL_MULTISITE) {
+      $result = db_query("SELECT page_callback, page_type, page_id, base_dir FROM {boost_cache_relationships} WHERE child_page_id = '%s' AND child_page_type = '%s' AND child_page_callback = '%s'", $data['page_id'], $data['page_type'], $data['page_callback']);
+    }
+    else {
+      $data['base_dir'] = isset($data['base_dir']) ? $data['base_dir'] : BOOST_FILE_PATH;
+      $result = db_query("SELECT page_callback, page_type, page_id, base_dir FROM {boost_cache_relationships} WHERE child_page_id = '%s' AND child_page_type = '%s' AND child_page_callback = '%s' AND base_dir = '%s'", $data['page_id'], $data['page_type'], $data['page_callback'], $data['base_dir']);
+    }
+
     while ($info = db_fetch_array($result)) {
-      $hash = 'relationship' . $info['page_callback'] . $info['page_type'] . $info['page_id'];
+      $hash = 'relationship' . $info['base_dir'] . $info['page_callback'] . $info['page_type'] . $info['page_id'];
       $results[$hash] = $info;
     }
   }
@@ -2359,13 +2391,24 @@ function boost_get_db($filename) {
 function boost_get_settings_db($router_item) {
   $settings = array();
   // Get a more exact match first
-  $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], BOOST_FILE_PATH, $router_item['page_id'], 0, 1));
+  if (BOOST_FLUSH_ALL_MULTISITE) {
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], $router_item['page_id'], 0, 1));
+
+    // Get for the content type
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], 0, 0, 1));
+
+    // Finally get the content container (node, view, term, ect...)
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $router_item['page_callback'], 0, 0, 0, 1));
+  }
+  else {
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], BOOST_FILE_PATH, $router_item['page_id'], 0, 1));
 
-  // Get for the content type
-  $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], BOOST_FILE_PATH, 0, 0, 1));
+    // Get for the content type
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], $router_item['page_type'], BOOST_FILE_PATH, 0, 0, 1));
 
-  // Finally get the content container (node, view, term, ect...)
-  $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], 0, BOOST_FILE_PATH, 0, 0, 1));
+    // Finally get the content container (node, view, term, ect...)
+    $settings[] = db_fetch_array(db_query_range("SELECT * FROM {boost_cache_settings} WHERE page_callback = '%s' AND page_type = '%s' AND base_dir = '%s' AND page_id = '%s'", $router_item['page_callback'], 0, BOOST_FILE_PATH, 0, 0, 1));
+  }
 
   return $settings;
 }
