? boost-610398.1.patch
? boost-610398_0.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.203
diff -u -p -r1.3.2.2.2.5.2.203 boost.module
--- boost.module	23 Oct 2009 02:56:20 -0000	1.3.2.2.2.5.2.203
+++ boost.module	28 Oct 2009 04:01:29 -0000
@@ -496,27 +496,36 @@ function boost_expire_node($node) {
   if (empty($node->nid)) {
     return FALSE;
   }
+  $data = array();
+  $paths = array();
 
   // Expire all relevant node pages from the static page cache to prevent serving stale content:
   if ($node->promote == 1) {
-    boost_cache_expire_derivative('<front>');
+    $paths[] = '<front>';
+  }
+  if (BOOST_NO_DATABASE) {
+    $paths[] = 'node/' . $node->nid;
+  }
+  else {
+    $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $node->nid);
   }
-  boost_cache_expire_derivative('node/' . $node->nid);
 
   // Get terms and flush their page
   if (module_exists('taxonomy') && BOOST_FLUSH_NODE_TERMS) {
     $tids = boost_taxonomy_node_get_tids($node->nid);
     $filenames = array();
     foreach ($tids as $tid) {
-      $filenames = array_merge($filenames, boost_get_db_term($tid));
-    }
-    foreach ($filenames as $filename) {
-      boost_cache_kill($filename['filename'], $filename['hash']);
+      if (BOOST_NO_DATABASE) {
+        $paths[] = 'taxonomy/term/' . $tid;
+      }
+      else {
+        $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'taxonomy', 'page_id' => $tid);
+      }
     }
   }
 
+  // Get CCK References and flush.
   if (BOOST_FLUSH_CCK_REFERENCES && module_exists('nodereference')) {
-    // Get CCK References and flush.
     $nids = array();
     $type = content_types($node->type);
     foreach ($type['fields'] as $field) {
@@ -530,14 +539,24 @@ function boost_expire_node($node) {
       }
     }
     foreach ($nids as $nid) {
-      boost_cache_expire_derivative('node/' . $nid);
+      if (BOOST_NO_DATABASE) {
+        $paths[] = 'node/' . $nid;
+      }
+      else {
+        $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $nid);
+      }
     }
 
     // Get CCK references pointing to this node and flush.
     if (module_exists('nodereferrer')) {
       $nids = nodereferrer_referrers($node->nid);
       foreach ($nids as $nid) {
-        boost_cache_expire_derivative('node/' . $nid['nid']);
+        if (BOOST_NO_DATABASE) {
+          $paths[] = 'node/' . $nid['nid'];
+        }
+        else {
+          $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'node', 'page_id' => $nid['nid']);
+        }
       }
     }
   }
@@ -545,11 +564,12 @@ function boost_expire_node($node) {
   if (BOOST_FLUSH_VIEWS && module_exists('views')) {
     $GLOBALS['_boost_router_item'] = isset($GLOBALS['_boost_router_item']) ? $GLOBALS['_boost_router_item'] : _boost_get_menu_router();
     $router_item = $GLOBALS['_boost_router_item'];
-    $data = array();
-    $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => $router_item['page_callback'], 'page_type' => $router_item['page_type'], 'page_id' => $router_item['page_id']);
-    $relationships = boost_cache_get_node_relationships($data);
-    boost_cache_expire_router($relationships);
+    $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']);
+    $data[] = boost_cache_get_node_relationships($relationship);
   }
+  boost_cache_expire_derivative($paths, TRUE);
+  boost_cache_expire_router($data);
 }
 
 /**
@@ -599,15 +619,18 @@ function boost_user($op, &$edit, &$accou
     case 'logout':
       boost_set_cookie($user, BOOST_TIME - 86400);
       break;
-    case 'insert':
-      // TODO: create user-specific cache directory.
-      break;
     case 'delete':
       // Expire the relevant user page from the static page cache to prevent serving stale content:
       if (!empty($account->uid)) {
-        boost_cache_expire_derivative('user/' . $account->uid);
+        if (BOOST_NO_DATABASE) {
+          $paths[] = 'user/' . $account->uid;
+          boost_cache_expire_derivative($paths, TRUE);
+        }
+        else {
+          $data[] = array('base_dir' => BOOST_FILE_PATH, 'page_callback' => 'user', 'page_id' => $account->uid);
+          boost_cache_expire_router($data);
+        }
       }
-      // TODO: recursively delete user-specific cache directory.
       break;
   }
 }
@@ -778,7 +801,7 @@ function boost_block_form_flush_submit(&
   }
   $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']);
   boost_cache_expire_router($data, TRUE);
-  boost_cache_expire_derivative($form['values']['path'], FALSE);
+  boost_cache_expire_derivative(array($form['values']['path']));
 }
 
 function boost_block_db_settings_form() {
@@ -1314,45 +1337,51 @@ function boost_cache_delete($flush = FAL
 /**
  * Finds all possible paths/redirects/aliases given the root path.
  *
- * @param $path
- *   Current URL
- * @param $db
- *   Expire by database lookup
+ * @param $paths
+ *   Array of current URLs
+ * @param $both
+ *   Expire database & file
  */
-function boost_cache_expire_derivative($path, $db = TRUE) {
+function boost_cache_expire_derivative($paths, $both = FALSE) {
   global $base_path;
-  $paths = array();
-
-  // Given path
-  $paths[] = $path;
 
-  // Special front page feed handling
-  if (BOOST_CACHE_XML && ($path = '' || $path = '<front>')) {
-    $paths[] = 'rss.xml';
-  }
-
-  // Path alias
-  $path_alias = url($path, array('absolute' => FALSE));
-  if ($base_path != '/') {
-    $path_alias = implode('/', array_diff_assoc(array_filter(explode('/', $path_alias)), array_filter(explode('/', $base_path))));
-  }
-  $paths[] = $path_alias;
+  foreach ($paths as $path) {
+    // Given path
+    $expire[] = $path;
 
-  // Path redirects
-  if (module_exists('path_redirect')) {
-    $path_redirects = boost_path_redirect_load(array('redirect' => $path));
-    if (isset($path_redirects)) {
-      foreach ($path_redirects as $path_redirect) {
-        $paths[] = $path_redirect['path'];
+    // Special front page feed handling
+    if (BOOST_CACHE_XML && ($path = '' || $path = '<front>')) {
+      $expire[] = 'rss.xml';
+    }
+
+    // Path alias
+    $path_alias = url($path, array('absolute' => FALSE));
+    if ($base_path != '/') {
+      $path_alias = implode('/', array_diff_assoc(array_filter(explode('/', $path_alias)), array_filter(explode('/', $base_path))));
+    }
+    $expire[] = $path_alias;
+
+    // Path redirects
+    if (module_exists('path_redirect')) {
+      $path_redirects = boost_path_redirect_load(array('redirect' => $path));
+      if (isset($path_redirects)) {
+        foreach ($path_redirects as $path_redirect) {
+          $expire[] = $path_redirect['path'];
+        }
       }
     }
   }
-  $paths = array_unique($paths);
-  if (BOOST_NO_DATABASE) {
-    boost_cache_expire_by_filename($paths);
+
+  $expire = array_unique($expire);
+  if (BOOST_NO_DATABASE ) {
+    boost_cache_expire_by_filename($expire);
+  }
+  elseif ($both && !BOOST_EXPIRE_NO_FLUSH) {
+    boost_cache_expire_by_db($expire);
+    boost_cache_expire_by_filename($expire);
   }
   else {
-    boost_cache_expire_by_db($paths);
+    boost_cache_expire_by_db($expire);
   }
 }
 
@@ -1468,11 +1497,15 @@ function boost_cache_expire_router($rout
 
   foreach ($router_items as $dblookup) {
     if (isset($dblookup['base_dir'])) {
-      if (isset($dblookup['page_id'])) {
+      if (isset($dblookup['page_id']) && isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
         $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
         db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
       }
-      elseif (isset($dblookup['page_type'])) {
+      elseif (isset($dblookup['page_id']) && isset($dblookup['page_callback'])) {
+        $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_id']);
+        db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_id']);
+      }
+      elseif (isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
         $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type']);
         db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type']);
       }
@@ -1485,11 +1518,15 @@ function boost_cache_expire_router($rout
       }
     }
     else {
-      if (isset($dblookup['page_id'])) {
+      if (isset($dblookup['page_id']) && isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
         $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
         db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
       }
-      elseif (isset($dblookup['page_type'])) {
+      elseif (isset($dblookup['page_id']) && isset($dblookup['page_callback'])) {
+        $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_id']);
+        db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_id']);
+      }
+      elseif (isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
         $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s'", $dblookup['page_callback'], $dblookup['page_type']);
         db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_type = '%s'", $dblookup['page_callback'], $dblookup['page_type']);
       }
@@ -2027,18 +2064,6 @@ function boost_get_settings_db($router_i
 }
 
 /**
- * Returns all cached pages associated with the taxonomy term.
- */
-function boost_get_db_term($term) {
-  $filenames = array();
-  $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE expire > 0 AND expire <> 434966400 AND page_id = '%s' AND page_callback = 'taxonomy'", $term);
-  while ($filename = db_fetch_array($result)) {
-    $filenames[] = $filename;
-  }
-  return $filenames;
-}
-
-/**
  * Checks various timestamps in the database.
  *
  * @param $set_max
Index: boost.rules.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/Attic/boost.rules.inc,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 boost.rules.inc
--- boost.rules.inc	21 Oct 2009 01:32:48 -0000	1.1.2.2
+++ boost.rules.inc	28 Oct 2009 04:01:29 -0000
@@ -28,7 +28,7 @@ function boost_rules_action_info() {
  */
 function boost_rules_action_clear_page($page, $settings) {
   if (boost_is_cached($path)) {
-    boost_cache_expire_derivative($page);
+    boost_cache_expire_derivative(array($page));
     if (BOOST_VERBOSE >= 5) {
       watchdog('boost', 'Rules flushed !page from static page cache.', array('!page' => $page));
     }
