? boost-617314.1.patch ? boost-617314.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.100 diff -u -p -r1.1.2.1.2.3.2.100 boost.admin.inc --- boost.admin.inc 30 Oct 2009 15:30:48 -0000 1.1.2.1.2.3.2.100 +++ boost.admin.inc 1 Nov 2009 03:09:59 -0000 @@ -749,13 +749,13 @@ function boost_admin_boost_performance_p // Clear database button $form['clear'] = array( '#type' => 'fieldset', - '#title' => t('Clear Boost\'s Database'), - '#description' => t('Warning: This gives you a clean slate for the boost database, use with caution. If you change the directories or file extensions (in "Boost directories and file extensions"), then clearing the database would be a good idea, but not required.'), + '#title' => t("Clear Boost's Database & File Cache"), + '#description' => t('Warning: This gives you a clean slate for the boost database & file system, use with caution. If you change the directories or file extensions (in "Boost directories and file extensions"), then pressing this button would be a good idea, but not required. If you changed the CSS or JavaScript and wish to push it out, you need to press this button.'), ); $form['clear']['boost_reset'] = array( '#type' => 'submit', - '#value' => t('Reset boost database: !records records', array('!records' => boost_count_db(2))), - '#submit' => array('boost_reset_database_submit'), + '#value' => t('Reset Button - Database Records: !records, Files: !files', array('!records' => boost_count_db(2), '!files' => boost_count_all_files(BOOST_ROOT_CACHE_DIR))), + '#submit' => array('boost_reset_database_file_submit'), ); // Form validation @@ -1084,6 +1084,35 @@ function boost_count_db($all = 0) { } /** + * Count the number of files in a folder + * + * @param string $dir + * Directory name, usually BOOST_ROOT_CACHE_DIR or /cache + */ +function boost_count_all_files($dirname) { + if (is_dir($dirname)) { + $dir_handle = opendir($dirname); + } + if (!$dir_handle) { + return 0; + } + + $files = 0; + while ($file = readdir($dir_handle)) { + if ($file != "." && $file != "..") { + if (!is_dir($dirname . "/" . $file)) { + $files++; + } + else { + $files += boost_count_all_files($dirname . "/" . $file); + } + } + } + closedir($dir_handle); + return $files; +} + +/** * Counts the number of pages in the core cache. */ function boost_count_core_db($all = FALSE) { @@ -1097,6 +1126,8 @@ function boost_clear_cache_submit() { $ignore = variable_get('boost_ignore_flush', 0); $GLOBALS['conf']['boost_ignore_flush'] = 0; if (boost_cache_clear_all()) { + boost_clear_cache_parallel(BOOST_PERM_FILE_PATH); + boost_clear_cache_parallel(BOOST_PERM_GZIP_FILE_PATH); drupal_set_message(t('Boost: Static page cache cleared.')); } else { @@ -1105,6 +1136,13 @@ function boost_clear_cache_submit() { $GLOBALS['conf']['boost_ignore_flush'] = $ignore; } +function boost_clear_cache_parallel($dir) { + $dirs = _boost_copy_file_get_domains($dir); + foreach ($dirs as $directory) { + watchdog('boost', $directory); + _boost_rmdir_rf($directory, TRUE, TRUE); + } +} /** * Flushes all expired pages from database @@ -1122,9 +1160,9 @@ function boost_clear_expired_cache_submi } /** - * Resets boost database & cache + * Resets boost database & cache directory */ -function boost_reset_database_submit() { +function boost_reset_database_file_submit() { $ignore = variable_get('boost_ignore_flush', 0); $GLOBALS['conf']['boost_ignore_flush'] = 0; if (boost_cache_clear_all()) { @@ -1132,6 +1170,7 @@ function boost_reset_database_submit() { db_query("TRUNCATE {boost_cache_settings}"); db_query("TRUNCATE {boost_cache_relationships}"); db_query("TRUNCATE {boost_crawler}"); + _boost_rmdir_rf(BOOST_ROOT_CACHE_DIR, TRUE, TRUE, TRUE); drupal_set_message(t('Boost: Static page cache & 4 database tables cleared.')); } else { Index: boost.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.install,v retrieving revision 1.2.2.1.2.3.2.67 diff -u -p -r1.2.2.1.2.3.2.67 boost.install --- boost.install 30 Oct 2009 15:24:46 -0000 1.2.2.1.2.3.2.67 +++ boost.install 1 Nov 2009 03:10:00 -0000 @@ -73,10 +73,17 @@ function boost_requirements($phase) { $cache_directories[] = BOOST_ROOT_CACHE_DIR; $cache_directories[] = BOOST_FILE_PATH; $cache_directories[] = BOOST_PERM_FILE_PATH; + foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) { + file_put_contents($dir . '/' . variable_get('boost_root_file', '.boost'), $dir); + } if (BOOST_GZIP) { $cache_directories[] = BOOST_GZIP_FILE_PATH; $cache_directories[] = BOOST_PERM_GZIP_FILE_PATH; + foreach (_boost_copy_file_get_domains(BOOST_PERM_GZIP_FILE_PATH) as $dir) { + file_put_contents($dir . '/' . variable_get('boost_root_file', '.boost'), $dir); + } } + $cache_directories = array_unique($cache_directories); $htaccess = stristr($_SERVER["SERVER_SOFTWARE"], 'apache') ? file_get_contents('.htaccess') : FALSE; if (BOOST_CRAWL_ON_CRON) { Index: boost.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v retrieving revision 1.3.2.2.2.5.2.215 diff -u -p -r1.3.2.2.2.5.2.215 boost.module --- boost.module 1 Nov 2009 00:10:07 -0000 1.3.2.2.2.5.2.215 +++ boost.module 1 Nov 2009 03:10:01 -0000 @@ -1393,6 +1393,12 @@ function boost_cache_delete($flush = FAL //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); + foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) { + file_put_contents($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); + } //Flush Cache if (file_exists(BOOST_FILE_PATH)) { @@ -1408,6 +1414,12 @@ function boost_cache_delete($flush = FAL //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); + foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) { + file_put_contents($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); + } } /** @@ -2495,6 +2507,14 @@ function boost_cache_css_js_files($buffe } _boost_copy_js_files(array_filter($js_files)); } + if (BOOST_CACHE_CSS || BOOST_CACHE_JS) { + foreach (_boost_copy_file_get_domains(BOOST_PERM_FILE_PATH) as $dir) { + file_put_contents($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); + } + } } /** @@ -2881,16 +2901,21 @@ function _boost_mkdir_p($pathname, $recu * optional nuke it all if true, otherwise kill only expired files * @param $first * id first call to this function + * @param $nuke + * clear it all, everything, ignore multisite restrictions */ -function _boost_rmdir_rf($dirname, $flush = TRUE, $first = TRUE) { +function _boost_rmdir_rf($dirname, $flush = TRUE, $first = TRUE, $nuke = FALSE) { + if (empty($dirname)) { + return FALSE; + } $empty = TRUE; // Start with an optimistic mindset - if ($first || (!$first && !file_exists($dirname . '/' . BOOST_ROOT_FILE))) { + if ($first || (!$first && ($nuke || !file_exists($dirname . '/' . BOOST_ROOT_FILE)))) { $files = glob($dirname . '/*', GLOB_NOSORT); if ($files) { foreach ($files as $file) { if (is_dir($file)) { - if (!_boost_rmdir_rf($file, $flush, FALSE)) { + if (!_boost_rmdir_rf($file, $flush, FALSE, $nuke)) { $empty = FALSE; } }