? boost-637002.patch
? boost-638390.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.251
diff -u -p -r1.3.2.2.2.5.2.251 boost.module
--- boost.module	16 Nov 2009 18:15:29 -0000	1.3.2.2.2.5.2.251
+++ boost.module	20 Nov 2009 22:30:13 -0000
@@ -1581,14 +1581,15 @@ function boost_cache_delete($flush = FAL
   //recreate dirs
   _boost_mkdir_p(BOOST_FILE_PATH);
   _boost_mkdir_p(BOOST_GZIP_FILE_PATH);
+
   //add in .boost root id file
-  file_put_contents(BOOST_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
-  file_put_contents(BOOST_GZIP_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_GZIP_FILE_PATH);
+  _boost_write_file_chmod(BOOST_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
+  _boost_write_file_chmod(BOOST_GZIP_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
   foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) {
-    file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+    _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
   }
   foreach (_boost_copy_file_get_domains(BOOST_PERM_GZIP_FILE_PATH) as $dir) {
-    file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+    _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
   }
 
   //Flush Cache
@@ -1602,14 +1603,15 @@ function boost_cache_delete($flush = FAL
   //recreate dirs
   _boost_mkdir_p(BOOST_FILE_PATH);
   _boost_mkdir_p(BOOST_GZIP_FILE_PATH);
+
   //add in .boost root id file
-  file_put_contents(BOOST_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
-  file_put_contents(BOOST_GZIP_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_GZIP_FILE_PATH);
+  _boost_write_file_chmod(BOOST_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
+  _boost_write_file_chmod(BOOST_GZIP_FILE_PATH . '/' . BOOST_ROOT_FILE, BOOST_FILE_PATH);
   foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) {
-    file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+    _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
   }
   foreach (_boost_copy_file_get_domains(BOOST_PERM_GZIP_FILE_PATH) as $dir) {
-    file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+    _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
   }
 }
 
@@ -2918,12 +2920,10 @@ function boost_cache_css_js_files($buffe
   }
   if (BOOST_CACHE_CSS || BOOST_CACHE_JS) {
     foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) {
-      _boost_mkdir_p($dir);
-      file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+      _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
     }
     foreach (_boost_copy_file_get_domains(BOOST_PERM_GZIP_FILE_PATH) as $dir) {
-      _boost_mkdir_p($dir);
-      file_put_contents($dir . '/' . BOOST_ROOT_FILE, $dir);
+      _boost_write_file_chmod($dir . '/' . BOOST_ROOT_FILE, $dir);
     }
   }
 }
@@ -3177,7 +3177,7 @@ function _boost_copy_file($src, $dest) {
     if (_boost_mkdir_p(dirname($destination))) {
       @copy($src, $destination);
       if (is_numeric(BOOST_PERMISSIONS_FILE)) {
-        @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
+        @chmod($destination, octdec(BOOST_PERMISSIONS_FILE));
       }
     }
   }
@@ -3194,12 +3194,7 @@ function _boost_copy_file($src, $dest) {
 function _boost_gz_copy_file($src, $dest) {
   $destinations = _boost_copy_file_get_domains($dest);
   foreach ($destinations as $destination) {
-    if (_boost_mkdir_p(dirname($destination))) {
-      @file_put_contents($destination, gzencode(file_get_contents($src), 9));
-      if (is_numeric(BOOST_PERMISSIONS_FILE)) {
-        @chmod($tempfile, octdec(BOOST_PERMISSIONS_FILE));
-      }
-    }
+    _boost_write_file_chmod($destination, gzencode(file_get_contents($src), 9));
   }
 }
 
@@ -3461,8 +3456,7 @@ document.cookie = 'boost-gzip=true' + ex
 </script>
 </head><body><h1>It works!</h1></body></html>
 ETO;
-    _boost_mkdir_p(dirname($filename));
-    file_put_contents($filename, gzencode($string, 9));
+    _boost_write_file_chmod($filename, gzencode($string, 9));
   }
 }
 
@@ -3481,6 +3475,27 @@ function _boost_inject_code($document, $
 }
 
 /**
+ * Create the dir, write the file, chmod the file.
+ *
+ * @param $filename
+ *  Path and filename to be created
+ * @param $data
+ *  data inside the file
+ */
+function _boost_write_file_chmod($filename, $data) {
+  if (_boost_mkdir_p(dirname($filename))) {
+    $bytes = @file_put_contents($filename, $data);
+    if ($bytes && is_numeric(BOOST_PERMISSIONS_FILE)) {
+      @chmod($filename, octdec(BOOST_PERMISSIONS_FILE));
+    }
+    return $bytes;
+  }
+  else {
+    return FALSE;
+  }
+}
+
+/**
  * Attempts to set the PHP maximum execution time.
  * See http://api.drupal.org/api/function/drupal_set_time_limit/7
  *
