? boost-585152.patch
? boost-585518.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.150
diff -u -p -r1.3.2.2.2.5.2.150 boost.module
--- boost.module	27 Sep 2009 06:47:55 -0000	1.3.2.2.2.5.2.150
+++ boost.module	29 Sep 2009 12:22:22 -0000
@@ -1266,40 +1266,50 @@ function boost_cache_get($path) {
  * @param $extension
  *   File extension for this mime type
  */
-function boost_cache_set($path, $data = '', $extension = BOOST_FILE_EXTENSION) {
+function boost_cache_set($path, $data, $extension = BOOST_FILE_EXTENSION) {
+  if (empty($data)) {
+    return FALSE;
+  }
+  $cached_at = date('Y-m-d H:i:s', BOOST_TIME);
   // Code commenting style based on what is being cached.
+  // Append the Boost footer with the relevant timestamps
   switch ($extension) {
     case BOOST_FILE_EXTENSION:
       $comment_start = '<!-- ';
       $comment_end = " -->\n";
       $expire = BOOST_CACHE_LIFETIME;
+      $expires_at = date('Y-m-d H:i:s', BOOST_TIME + $expire);
+      $comment = $comment_start . str_replace(array('%cached_at', '%expires_at'), array($cached_at, $expires_at), BOOST_BANNER) . $comment_end;
+      $data = _boost_inject_code(rtrim($data), "\n" . $comment);
       break;
     case BOOST_XML_EXTENSION:
       $comment_start = '<!-- ';
       $comment_end = " -->\n";
       $expire = BOOST_CACHE_XML_LIFETIME;
+      $expires_at = date('Y-m-d H:i:s', BOOST_TIME + $expire);
+      $comment = $comment_start . str_replace(array('%cached_at', '%expires_at'), array($cached_at, $expires_at), BOOST_BANNER) . $comment_end;
+      $data = rtrim($data) . "\n" . $comment;
       break;
     case BOOST_JSON_EXTENSION:
       $comment_start = '/* ';
       $comment_end = " */\n";
       $expire = BOOST_CACHE_JSON_LIFETIME;
+      $expires_at = date('Y-m-d H:i:s', BOOST_TIME + $expire);
+      $comment = $comment_start . str_replace(array('%cached_at', '%expires_at'), array($cached_at, $expires_at), BOOST_BANNER) . $comment_end;
+      $data = rtrim($data) . "\n" . $comment;
       break;
   }
-  // Append the Boost footer with the relevant timestamps
-  $cached_at = date('Y-m-d H:i:s', BOOST_TIME);
-  $expires_at = date('Y-m-d H:i:s', BOOST_TIME + $expire);
-  $data = rtrim($data) . "\n" . $comment_start . str_replace(array('%cached_at', '%expires_at'), array($cached_at, $expires_at), BOOST_BANNER) . $comment_end;
 
-  // Invoke hook_boost_preprocess($path, $data)
+  // Invoke hook_boost_preprocess($path, $data, $extension)
   foreach (module_implements('boost_preprocess') as $module) {
-    if (($result = module_invoke($module, 'boost_preprocess', $data)) != NULL) {
+    if (($result = module_invoke($module, 'boost_preprocess', $path, $data, $extension)) != NULL) {
       $data = $result;
     }
   }
 
   // Execute the pre-process function if one has been defined
   if (function_exists(BOOST_PRE_PROCESS_FUNCTION)) {
-    $data = call_user_func(BOOST_PRE_PROCESS_FUNCTION, $data);
+    $data = call_user_func(BOOST_PRE_PROCESS_FUNCTION, $path, $data, $extension);
   }
   db_set_active();
 
@@ -1312,9 +1322,9 @@ function boost_cache_set($path, $data = 
   // Create or update the static files as needed
   if (($filename = boost_file_path($path, TRUE, $extension)) && (BOOST_OVERWRITE_FILE || !file_exists($filename) || boost_db_is_expired($filename))) {
     // Special handling of the front page for aggressive gzip test
-    if ($path == '' && BOOST_AGGRESSIVE_GZIP) {
-      _boost_generate_gzip_test();
-      boost_cache_write($filename, _boost_gzip_test_inject_iframe($data));
+    if ($path == '' && BOOST_AGGRESSIVE_GZIP && $extension == BOOST_FILE_EXTENSION) {
+      _boost_generate_gzip_test_file();
+      boost_cache_write($filename, _boost_inject_code($data, '<iframe src="/boost-gzip-cookie-test.html" style="width:0px; height:0px; border: 0px"></iframe>' . "\n"));
     }
     else {
       boost_cache_write($filename, $data);
@@ -2251,9 +2261,9 @@ function _boost_variable_set($name, $val
 }
 
 /**
- * Generate iframe gzip cookie test html.
+ * Generate iframe gzip cookie test html file.
  */
-function _boost_generate_gzip_test() {
+function _boost_generate_gzip_test_file() {
   $filename = BOOST_ROOT_CACHE_DIR . '/' . BOOST_PERM_GZ_DIR . '/boost-gzip-cookie-test.html.gz';
   if (!file_exists($filename)) {
     $string = <<<ETO
@@ -2276,10 +2286,17 @@ ETO;
 }
 
 /**
- * Inject iframe gzip cookie test.
+ * Inject code into document.
+ *
+ * @param $document
+ *  string containing html document.
+ * @param $html_code
+ *  string containing html snippit.
+ * @param $point
+ *  string of the insertion point
  */
-function _boost_gzip_test_inject_iframe($data) {
- return str_replace('</body>', '<iframe src="/boost-gzip-cookie-test.html" style="width:0px; height:0px; border: 0px"></iframe>' . "\n" . '</body>', $data);
+function _boost_inject_code($document, $html_code, $point = '</body>') {
+ return str_replace($point, $html_code . $point, $document);
 }
 
 //////////////////////////////////////////////////////////////////////////////
