? boost-601836.patch
? boost-602048.patch
Index: boost.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v
retrieving revision 1.1.2.1.2.3.2.85
diff -u -p -r1.1.2.1.2.3.2.85 boost.admin.inc
--- boost.admin.inc	10 Oct 2009 07:58:35 -0000	1.1.2.1.2.3.2.85
+++ boost.admin.inc	12 Oct 2009 08:50:00 -0000
@@ -7,7 +7,7 @@
  */
 
 //////////////////////////////////////////////////////////////////////////////
-// Boost settings form
+// Performance Page Edits
 
 /**
  * Performs alterations to the system settings form before it is rendered.
@@ -32,16 +32,7 @@ function boost_admin_performance_page($f
  * Process system_themes_form form submissions.
  */
 function boost_admin_performance_page_submit($form, &$form_state) {
-  variable_del('boost_previously');
-  extract($form_state['values'], EXTR_SKIP | EXTR_REFS);
-
-  if (empty($boost_enabled) && !empty($boost_previously)) { // the cache was previously enabled
-    variable_set('boost_ignore_flush', 0);
-    if (boost_cache_clear_all()) {
-      drupal_set_message(t('Boost: Static page cache cleared.'));
-    }
-  }
-  elseif ($boost_ignore_flush == 0 && (variable_get('preprocess_css', FALSE)==TRUE || variable_get('preprocess_js', FALSE)==TRUE)) {
+  if (variable_get('boost_ignore_flush', 0) == 0 && (variable_get('preprocess_css', FALSE)==TRUE || variable_get('preprocess_js', FALSE)==TRUE)) {
     if (boost_cache_clear_all()) {
       drupal_set_message(t('Boost: Static page cache cleared.'), 'warning');
     }
@@ -49,6 +40,14 @@ function boost_admin_performance_page_su
 }
 
 /**
+ * Flushes core page cache
+ */
+function boost_clear_core_page_cache_submit() {
+  cache_clear_all('*', 'cache_page', TRUE);
+  drupal_set_message(t('Core page cache cleared.'));
+}
+
+/**
  * Submit callback; clear system caches.
  */
 function boost_admin_clear_cache_submit($form, &$form_state) {
@@ -63,6 +62,9 @@ function boost_admin_clear_cache_submit(
   }
 }
 
+//////////////////////////////////////////////////////////////////////////////
+// Boost Settings Form
+
 /**
  * Form builder; Displays Boost's configuration page.
  *
@@ -191,8 +193,7 @@ function boost_admin_boost_performance_p
     '#description'   => $description,
   );
 
-
-  // directories
+  // Directories
   $form['directories'] = array(
     '#type'          => 'fieldset',
     '#title'         => t('Boost directories and file extensions'),
@@ -258,7 +259,7 @@ function boost_admin_boost_performance_p
     '#title'         => t('Character used to replace "?"'),
     '#default_value' => BOOST_CHAR,
     '#size'          => 15,
-    '#maxlength'     => 255,
+    '#maxlength'     => 16,
     '#required'      => TRUE,
     '#description'   => t('Best to leave at _'),
   );
@@ -322,7 +323,7 @@ function boost_admin_boost_performance_p
     '#title'         => t('Character used to replace "?" in the permanent dir'),
     '#default_value' => BOOST_PERM_CHAR,
     '#size'          => 15,
-    '#maxlength'     => 255,
+    '#maxlength'     => 16,
     '#required'      => TRUE,
     '#description'   => t('Best to leave at _'),
   );
@@ -475,7 +476,7 @@ function boost_admin_boost_performance_p
   $form['advanced']['boost_ignore_flush'] = array(
     '#type'          => 'radios',
     '#title'         => t('Ignore cache flushing'),
-    '#default_value' => BOOST_IGNORE_FLUSH,
+    '#default_value' => 0,
     '#options'       => array(
       0 => t('Disabled'),
       1 => t('Only Ignore Clear Entire Cache Commands (Recommended if caching css/js files)'),
@@ -571,7 +572,6 @@ function boost_admin_boost_performance_p
     '#description'   => t('Be careful when choosing more then 2 threads.'),
   );
   $total = boost_crawler_total_count();
-  //variable_get
   $number_done = min($total, unserialize(db_result(db_query("SELECT value FROM {variable} WHERE name = 'boost_crawler_position'")))) + 1;
   $crawl_rate = round((BOOST_TIME - variable_get('boost_crawler_start_time', BOOST_TIME))/$number_done, 2);
   if (boost_crawler_threads_alive() && $number_done > 0 && !variable_get('boost_crawler_stopped', FALSE) && round(($total - $number_done)/$crawl_rate) > 0) {
@@ -605,7 +605,6 @@ function boost_admin_boost_performance_p
     );
   }
 
-
   // Apache .htaccess settings generation
   $htaccess = boost_admin_generate_htaccess(variable_get('boost_server_name_http_host', '%{SERVER_NAME}'), variable_get('boost_document_root', '%{DOCUMENT_ROOT}'));
   $form['htaccess'] = array(
@@ -625,7 +624,6 @@ function boost_admin_boost_performance_p
     ),
     '#description'   => t('Best to leave these as %{}, only try the last option(s) if boost is still not working.'),
   );
-
   // Set DOCUMENT_ROOT
   $drupal_subdir = rtrim($base_path, '/');
   $document_root = str_replace("\\", '/', getcwd()); // fix windows dir slashes
@@ -670,6 +668,7 @@ function boost_admin_boost_performance_p
     '#submit' => array('boost_reset_database_submit'),
   );
 
+  // Form validation
   $form['#validate'][] = 'boost_admin_boost_performance_page_validate';
   return system_settings_form($form);
 }
@@ -678,34 +677,54 @@ function boost_admin_boost_performance_p
  * validate system_themes_form form submissions.
  */
 function boost_admin_boost_performance_page_validate($form, &$form_state) {
-  $form_state['values']['boost_previously'] = variable_get('boost_enabled', '');
+  $boost_previously = variable_get('boost_enabled', '');
   extract($form_state['values'], EXTR_SKIP | EXTR_REFS);
   if (BOOST_MULTISITE_SINGLE_DB) {
     $boost_file_path = boost_cache_directory(NULL, FALSE);
   }
 
-  if (!empty($boost_enabled)) {
+  // Boost enabled/disabled logic
+  if ($boost_enabled != CACHE_DISABLED) {
     // The cache is enabled
     // Ensure the cache directory exists or can be created:
     _boost_mkdir_p($boost_file_path);
     file_check_directory($boost_file_path, FILE_CREATE_DIRECTORY, 'boost_file_path');
   }
+  elseif ($boost_enabled == CACHE_DISABLED && $boost_previously != CACHE_DISABLED) {
+    // The cache was previously enabled
+    variable_set('boost_ignore_flush', 0);
+    if (boost_cache_clear_all()) {
+      drupal_set_message(t('Boost: Static page cache cleared.'));
+    }
+  }
 
-//   if (strpos($boost_file_extension, '.') !== 0) {
-//     form_set_error('boost_file_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_file_extension)));
-//   }
+  // Validate file extensions
+  if (BOOST_CACHE_HTML && isset($boost_file_extension) && strpos($boost_file_extension, '.') !== 0) {
+    form_set_error('boost_file_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_file_extension)));
+  }
+  if (BOOST_CACHE_XML && isset($boost_xml_extension) && strpos($boost_xml_extension, '.') !== 0) {
+    form_set_error('boost_xml_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_xml_extension)));
+  }
+  if (BOOST_CACHE_JSON && isset($boost_json_extension) && strpos($boost_json_extension, '.') !== 0) {
+    form_set_error('boost_json_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_json_extension)));
+  }
+  if (BOOST_CACHE_CSS && isset($boost_css_extension) && strpos($boost_css_extension, '.') !== 0) {
+    form_set_error('boost_css_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_css_extension)));
+  }
+  if (BOOST_CACHE_JS && isset($boost_js_extension) && strpos($boost_js_extension, '.') !== 0) {
+    form_set_error('boost_js_extension', t('Cache file extension %extension must begin with a period.', array('%extension' => $boost_js_extension)));
+  }
 
+  // Check that the preprocess function exists.
   if (!empty($boost_pre_process_function) && !is_callable($boost_pre_process_function)) {
     form_set_error('boost_pre_process_function', t('Pre-process function %function() does not exist.', array('%function' => $boost_pre_process_function)));
   }
 }
 
 function boost_admin_site_offline_submit($form, &$form_state) {
-  if (!empty($form_state['values']['site_offline'])) {
-    if (BOOST_CLEAR_CACHE_OFFLINE) {
-      if (boost_cache_clear_all()) {
-        drupal_set_message(t('Boost: Static page cache cleared.'), 'warning');
-      }
+  if (!empty($form_state['values']['site_offline']) && BOOST_CLEAR_CACHE_OFFLINE) {
+    if (boost_cache_clear_all()) {
+      drupal_set_message(t('Boost: Static page cache cleared.'), 'warning');
     }
   }
 }
@@ -772,12 +791,12 @@ function boost_admin_generate_htaccess($
   $permanent_dir = !(BOOST_PERM_NORMAL_DIR == '') ? '/' . BOOST_PERM_NORMAL_DIR : '';
 
   // with a \ slash
-  $html = '\\' . BOOST_FILE_EXTENSION;
-  $xml = '\\' . BOOST_XML_EXTENSION;
-  $css = '\\' . BOOST_CSS_EXTENSION;
-  $js = '\\' . BOOST_JS_EXTENSION;
-  $json = '\\' . BOOST_JSON_EXTENSION;
-  $gz = '\\' . BOOST_GZIP_EXTENSION;
+  $html = str_replace('.', '\\.', BOOST_FILE_EXTENSION);
+  $xml  = str_replace('.', '\\.', BOOST_XML_EXTENSION);
+  $css  = str_replace('.', '\\.', BOOST_CSS_EXTENSION);
+  $js   = str_replace('.', '\\.', BOOST_JS_EXTENSION);
+  $json = str_replace('.', '\\.', BOOST_JSON_EXTENSION);
+  $gz   = str_replace('.', '\\.', BOOST_GZIP_EXTENSION);
 
   // no slash
   $_html = BOOST_FILE_EXTENSION;
@@ -789,7 +808,7 @@ function boost_admin_generate_htaccess($
 
   $char = BOOST_CHAR;
   $permanent_char = BOOST_PERM_CHAR;
-  $server_ip = str_replace('.', '\.', $_SERVER['SERVER_ADDR']);
+  $server_ip = str_replace('.', '\\.', $_SERVER['SERVER_ADDR']);
 
 
   // Generate the rules
@@ -969,12 +988,14 @@ function boost_count_core_db($all = FALS
  * Flushes boost page cache
  */
 function boost_clear_cache_submit() {
+  $ignore = variable_get('boost_ignore_flush', 0);
   if (boost_cache_clear_all()) {
     drupal_set_message(t('Boost: Static page cache cleared.'));
   }
   else {
     drupal_set_message(t('Boost: Set "Ignore cache flushing:" to \'Disabled\' in the <a href="!link">boost advanced settings</a> & try again.', array('!link' => url('admin/settings/performance/boost', array('fragment' => 'edit-boost-ignore-flush-0-wrapper')))), 'warning');
   }
+  variable_set('boost_ignore_flush', $ignore);
 }
 
 
@@ -982,26 +1003,21 @@ function boost_clear_cache_submit() {
  * Flushes all expired pages from database
  */
 function boost_clear_expired_cache_submit() {
+  $ignore = variable_get('boost_ignore_flush', 0);
   if (boost_cache_db_expire()) {
     drupal_set_message(t('Boost: Expired stale files from static page cache.'));
   }
   else {
     drupal_set_message(t('Boost: Set "Ignore cache flushing:" to \'Disabled\' OR \'Only Ignore Complete Flushes\' in the <a href="@link">boost advanced settings</a> & try again.', array('@link' => url('admin/settings/performance/boost', array('fragment' => 'edit-boost-ignore-flush-0-wrapper')))), 'warning');
   }
-}
-
-/**
- * Flushes core page cache
- */
-function boost_clear_core_page_cache_submit() {
-  cache_clear_all('*', 'cache_page', TRUE);
-  drupal_set_message(t('Core page cache cleared.'));
+  variable_set('boost_ignore_flush', $ignore);
 }
 
 /**
  * Resets boost database & cache
  */
 function boost_reset_database_submit() {
+  $ignore = variable_get('boost_ignore_flush', 0);
   if (boost_cache_clear_all()) {
     db_query("TRUNCATE {boost_cache}");
     db_query("TRUNCATE {boost_cache_settings}");
@@ -1010,6 +1026,7 @@ function boost_reset_database_submit() {
   else {
     drupal_set_message(t('Boost: Set "Ignore cache flushing:" to \'Disabled\' in the <a href="!link">boost advanced settings</a> & try again.', array('!link' => url('admin/settings/performance/boost', array('fragment' => 'edit-boost-ignore-flush-0-wrapper')))), 'warning');
   }
+  variable_set('boost_ignore_flush', $ignore);
 }
 
 /**
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.185
diff -u -p -r1.3.2.2.2.5.2.185 boost.module
--- boost.module	12 Oct 2009 07:50:51 -0000	1.3.2.2.2.5.2.185
+++ boost.module	12 Oct 2009 08:50:01 -0000
@@ -61,7 +61,6 @@ define('BOOST_CLEAR_CACHE_OFFLINE',  var
 define('BOOST_HALT_ON_ERRORS',       variable_get('boost_halt_on_errors', FALSE));
 define('BOOST_HALT_ON_MESSAGES',     variable_get('boost_halt_on_messages', TRUE));
 define('BOOST_CACHE_QUERY',          variable_get('boost_cache_query', TRUE));
-define('BOOST_IGNORE_FLUSH',         variable_get('boost_ignore_flush', 0));
 define('BOOST_PERMISSIONS_FILE',     variable_get('boost_permissions_file', ''));
 define('BOOST_PERMISSIONS_DIR',      variable_get('boost_permissions_dir', ''));
 define('BOOST_OVERWRITE_FILE',       variable_get('boost_overwrite_file', FALSE));
@@ -1201,7 +1200,7 @@ function boost_is_cached($path) {
  * Deletes all files currently in the cache.
  */
 function boost_cache_clear_all() {
-  if (BOOST_IGNORE_FLUSH == 0) {
+  if (variable_get('boost_ignore_flush', 0) == 0) {
     boost_cache_clear_all_db();
     boost_cache_delete(TRUE);
     if (BOOST_VERBOSE >= 5) {
@@ -1403,7 +1402,7 @@ function boost_cache_expire_router($rout
  *   Override BOOST_EXPIRE_NO_FLUSH setting
  */
 function boost_cache_kill($filename, $hash = '', $force_flush = FALSE) {
-  if (BOOST_IGNORE_FLUSH < 3 && strstr($filename, BOOST_FILE_PATH)) {
+  if (variable_get('boost_ignore_flush', 0) < 3 && strstr($filename, BOOST_FILE_PATH)) {
     if ($hash == '') {
       $hash = md5($filename);
     }
@@ -1431,7 +1430,7 @@ function boost_cache_kill($filename, $ha
  * TODO del empty dirs if enabled
  */
 function boost_cache_db_expire() {
-  if (BOOST_IGNORE_FLUSH < 2) {
+  if (variable_get('boost_ignore_flush', 0) < 2) {
     $result = db_query('SELECT filename, hash FROM {boost_cache} WHERE expire BETWEEN 1 AND %d', BOOST_TIME);
     while ($boost = db_fetch_array($result)) {
       boost_cache_kill($boost['filename'], $boost['hash'], TRUE);
