? boost-597156..1patch
? boost-597156.1.patch
? boost-597156.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.189
diff -u -p -r1.3.2.2.2.5.2.189 boost.module
--- boost.module	14 Oct 2009 03:15:32 -0000	1.3.2.2.2.5.2.189
+++ boost.module	14 Oct 2009 08:51:24 -0000
@@ -754,8 +754,13 @@ function boost_block_flush_form() {
 
 function boost_block_form_flush_submit(&$form_state, $form) {
   $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('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);
+
 }
 
 function boost_block_db_settings_form() {
@@ -980,8 +985,11 @@ function _boost_ob_handler() {
   // Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here.
   chdir(dirname($_SERVER['SCRIPT_FILENAME']));
 
+  // Very late cache canceling
   $GLOBALS['_boost_router_item'] = isset($GLOBALS['_boost_router_item']) ? $GLOBALS['_boost_router_item'] : _boost_get_menu_router();
-  if ($GLOBALS['_boost_router_item']['page_callback'] == 'search404_page') {
+  if (   $GLOBALS['_boost_router_item']['page_callback'] == 'search404_page'
+      || $GLOBALS['_boost_router_item']['page_callback'] == 'fivestar_vote'
+      ) {
     $GLOBALS['_boost_cache_this'] = FALSE;
   }
   if (function_exists('error_get_last')) {
@@ -1013,60 +1021,56 @@ function _boost_ob_handler() {
   // 200 then TODO: remove that entry from the cache.
   if (!empty($buffer)) {
     $status = boost_get_http_status();
-    $type = boost_get_content_type();
-    switch ($type) {
-      case 'text/html':
-        if ($status == 200 && $GLOBALS['_boost_cache_this']) {
-          if (BOOST_ASYNCHRONOUS_OUTPUT) {
-            boost_async_opp($buffer, FALSE, 'text/html');
-          }
-          boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_FILE_EXTENSION);
-          boost_cache_css_js_files($buffer);
+    $types = implode(', ', boost_get_content_type());
+    if (stristr($types, 'text/javascript')) {
+      if ($status == 200 & $GLOBALS['_boost_cache_this']) {
+        if (BOOST_ASYNCHRONOUS_OUTPUT) {
+          boost_async_opp($buffer, FALSE, 'text/javascript');
         }
-        elseif ($status == 404 || $status == 403) {
-          // Kill cache entry if it exists
-          $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_FILE_EXTENSION);
-          if ($filename) {
-            $hash = md5($filename);
-            boost_cache_kill($filename, $hash, TRUE);
-            boost_remove_db($filename, $hash);
-          }
+        boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_JSON_EXTENSION);
+      }
+      elseif ($status == 404 || $status == 403) {
+        $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_JSON_EXTENSION);
+        if ($filename) {
+          $hash = md5($filename);
+          boost_cache_kill($filename, $hash, TRUE);
+          boost_remove_db($filename, $hash);
         }
-        break;
-      case 'application/rss':
-      case 'text/xml':
-      case 'application/rss+xml':
-        if ($status == 200 && $GLOBALS['_boost_cache_this']) {
-          if (BOOST_ASYNCHRONOUS_OUTPUT) {
-            boost_async_opp($buffer, FALSE, 'text/xml');
-          }
-          boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION);
+      }
+    }
+    elseif (stristr($types, 'application/rss') || stristr($types, 'text/xml') || stristr($types, 'application/rss+xml')) {
+      if ($status == 200 && $GLOBALS['_boost_cache_this']) {
+        if (BOOST_ASYNCHRONOUS_OUTPUT) {
+          boost_async_opp($buffer, FALSE, 'text/xml');
         }
-        elseif ($status == 404 || $status == 403) {
-          $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_XML_EXTENSION);
-          if ($filename) {
-            $hash = md5($filename);
-            boost_cache_kill($filename, $hash, TRUE);
-            boost_remove_db($filename, $hash);
-          }
+        boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION);
+      }
+      elseif ($status == 404 || $status == 403) {
+        $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_XML_EXTENSION);
+        if ($filename) {
+          $hash = md5($filename);
+          boost_cache_kill($filename, $hash, TRUE);
+          boost_remove_db($filename, $hash);
         }
-        break;
-      case 'text/javascript':
-        if ($status == 200 & $GLOBALS['_boost_cache_this']) {
-          if (BOOST_ASYNCHRONOUS_OUTPUT) {
-            boost_async_opp($buffer, FALSE, 'text/javascript');
-          }
-          boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_JSON_EXTENSION);
+      }
+    }
+    elseif (stristr($types, 'text/html')) {
+      if ($status == 200 && $GLOBALS['_boost_cache_this']) {
+        if (BOOST_ASYNCHRONOUS_OUTPUT) {
+          boost_async_opp($buffer, FALSE, 'text/html');
         }
-        elseif ($status == 404 || $status == 403) {
-          $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_JSON_EXTENSION);
-          if ($filename) {
-            $hash = md5($filename);
-            boost_cache_kill($filename, $hash, TRUE);
-            boost_remove_db($filename, $hash);
-          }
+        boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_FILE_EXTENSION);
+        boost_cache_css_js_files($buffer);
+      }
+      elseif ($status == 404 || $status == 403) {
+        // Kill cache entry if it exists
+        $filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_FILE_EXTENSION);
+        if ($filename) {
+          $hash = md5($filename);
+          boost_cache_kill($filename, $hash, TRUE);
+          boost_remove_db($filename, $hash);
         }
-        break;
+      }
     }
   }
 }
@@ -1079,7 +1083,12 @@ function _boost_ob_handler() {
  * has overridden the content type.
  */
 function boost_get_content_type() {
-  return array_pop(explode('content-type: ', array_shift(explode('; charset=', array_shift(explode("\n", strtolower(drupal_get_headers())))))));
+  $headers = explode("content-type: ", strtolower(drupal_get_headers()));
+  $types = array();
+  foreach ($headers as $header) {
+    $types[] = array_shift(explode('; charset=', $header));
+  }
+  return $types;
 }
 
 /**
@@ -1088,12 +1097,12 @@ function boost_get_content_type() {
  */
 function boost_get_http_status() {
   $headers = explode("\n", drupal_get_headers());
-  if (count($headers) < 2) {
-    return 200;
+  preg_match('!^.*\s+(\d+)!', array_pop($headers), $matches);
+  if (isset($matches[1])) {
+    return $matches[1];
   }
   else {
-    preg_match('!^.*\s+(\d+)!', array_pop($headers), $matches);
-    return $matches[1];
+    return 200;
   }
 }
 
@@ -1271,11 +1280,17 @@ function boost_cache_expire_derivative($
   // 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 != '/') {
-    $paths[] = implode('/', array_diff_assoc(array_filter(explode('/', $path_alias)), array_filter(explode('/', $base_path))));
+    $path_alias = implode('/', array_diff_assoc(array_filter(explode('/', $path_alias)), array_filter(explode('/', $base_path))));
   }
+  $paths[] = $path_alias;
 
   // Path redirects
   if (module_exists('path_redirect')) {
@@ -1299,13 +1314,22 @@ function boost_cache_expire($paths) {
   $hashes = array();
   // Get all cache files directly associated with this path
   foreach (array_unique($paths) as $path) {
-    $html = boost_file_path($path, FALSE, BOOST_FILE_EXTENSION);
+    // With URL Variables
+    $html = boost_file_path($path, TRUE, BOOST_FILE_EXTENSION);
     if ($html === FALSE) {
       continue;
     }
+    $xml  = boost_file_path($path, TRUE, BOOST_XML_EXTENSION);
+    $json = boost_file_path($path, TRUE, BOOST_JSON_EXTENSION);
+    // Hash the paths
+    $hashes[] = md5($html);
+    $hashes[] = md5($xml);
+    $hashes[] = md5($json);
+
+    // Without URL Variables
+    $html = boost_file_path($path, FALSE, BOOST_FILE_EXTENSION);
     $xml  = boost_file_path($path, FALSE, BOOST_XML_EXTENSION);
     $json = boost_file_path($path, FALSE, BOOST_JSON_EXTENSION);
-
     // Hash the paths
     $hashes[] = md5($html);
     $hashes[] = md5($xml);
@@ -2027,6 +2051,9 @@ function boost_file_path($path, $query =
     if ($query) {
       $path .= $GLOBALS['_boost_query'];
     }
+    else {
+      $path .= BOOST_CHAR;
+    }
   }
   else {
     $path .= $GLOBALS['_boost_query'];
