? boost-182686.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.22 diff -u -p -r1.1.2.1.2.3.2.22 boost.admin.inc --- boost.admin.inc 6 Jun 2009 07:50:23 -0000 1.1.2.1.2.3.2.22 +++ boost.admin.inc 8 Jun 2009 04:49:33 -0000 @@ -99,13 +99,6 @@ function boost_admin_settings($form = ar '#required' => TRUE, '#description' => t('The file extension to append to the file name of the generated cache files. Note that this setting is of no relevance to any public URLs, and it is strongly recommended to leave this as the default \'.html\' unless you know what you are doing. If you change this, you must also change the URL rewrite rules in your web server configuration (.htaccess for Apache, lighttpd.conf for Lighttpd), or caching will not work.'), ); - /*$form['advanced']['boost_fetch_method'] = array( // not needed for now - '#type' => 'select', - '#title' => t('Page fetch method'), - '#default_value' => BOOST_FETCH_METHOD, - '#options' => array('php' => t('PHP fopen() wrapper'), 'wget' => t('Wget shell command'), 'curl' => t('curl shell command')), - '#description' => t('The method used to retrieve the contents of the Drupal pages to be cached. The default should work in most cases.'), - );*/ $form['advanced']['boost_pre_process_function'] = array( '#type' => 'textfield', '#title' => t('Pre-process function'), @@ -121,6 +114,12 @@ function boost_admin_settings($form = ar '#maxlength' => 255, '#description' => t('If you are synchronizing the generated static cache files to an external server through some means such as SFTP or rsync, you can enter a shell command to be executed following a successful cron-triggered cache update. Note that this is an advanced setting that should normally be left blank.'), );*/ + $form['advanced']['boost_cache_xml'] = array( + '#type' => 'checkbox', + '#title' => t('Cache .xml & /feed'), + '#default_value' => BOOST_CACHE_XML, + '#description' => t('Boost will cache .xml and /feed urls as xml data.'), + ); $form['advanced']['boost_only_ascii_path'] = array( '#type' => 'checkbox', '#title' => t('Only allow ASCII characters in path'), Index: boost.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v retrieving revision 1.3.2.2.2.5.2.48 diff -u -p -r1.3.2.2.2.5.2.48 boost.module --- boost.module 6 Jun 2009 07:50:23 -0000 1.3.2.2.2.5.2.48 +++ boost.module 8 Jun 2009 04:49:33 -0000 @@ -15,6 +15,7 @@ define('BOOST_ROOT_CACHE_PATH', 'ca define('BOOST_MULTISITE_SINGLE_DB', variable_get('boost_multisite_single_db', FALSE)); define('BOOST_FILE_PATH', BOOST_MULTISITE_SINGLE_DB ? boost_cache_directory(NULL, FALSE) : variable_get('boost_file_path', boost_cache_directory(NULL, FALSE))); define('BOOST_FILE_EXTENSION', variable_get('boost_file_extension', '.html')); +define('BOOST_XML_EXTENSION', variable_get('boost_xml_extension', '.xml')); define('BOOST_MAX_PATH_DEPTH', 10); define('BOOST_CACHEABILITY_OPTION', variable_get('boost_cacheability_option', 0)); define('BOOST_CACHEABILITY_PAGES', variable_get('boost_cacheability_pages', '')); @@ -27,6 +28,7 @@ define('BOOST_GZIP', var define('BOOST_GZIP_FILE_PATH', str_replace(BOOST_ROOT_CACHE_PATH . '/', BOOST_ROOT_CACHE_PATH . '/gz/', BOOST_FILE_PATH)); define('BOOST_CLEAR_CACHE_OFFLINE', variable_get('boost_clear_cache_offline', TRUE)); define('BOOST_HALT_ON_ERRORS', variable_get('boost_halt_on_errors', FALSE)); +define('BOOST_CACHE_XML', variable_get('boost_cache_xml', TRUE)); // This cookie is set for all authenticated users, so that they can be // excluded from caching (or in the future get a user-specific cached page): @@ -399,6 +401,9 @@ function _boost_ob_handler($buffer) { if (_boost_get_content_type() == 'text/html') { boost_cache_set($GLOBALS['_boost_path'], $buffer); } + else if (_boost_get_content_type() == ('application/rss' || 'text/xml' || 'application/rss+xml')) { + boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION); + } } // Allow the page request to finish up normally @@ -458,12 +463,13 @@ function boost_is_cacheable($path) { if ( $normal_path == 'user' || preg_match('!^user/(login|register|password)!', $normal_path) || preg_match('!^admin!', $normal_path) - || preg_match('!/feed$!', $normal_path) - || preg_match('!\.xml$!', $normal_path) || preg_match('!comment/reply$!', $normal_path) ) { return FALSE; } + if (!BOOST_CACHE_XML && (preg_match('!/feed$!', $normal_path) || preg_match('!\.xml$!', $normal_path))) { + return FALSE; + } // Match the user's cacheability settings against the path if (BOOST_CACHEABILITY_OPTION == 2) { @@ -524,14 +530,20 @@ function boost_cache_expire_all() { * Finds all possible paths given the root path. */ function boost_cache_expire_derivative($path, $wildcard = FALSE) { + global $base_path; #path alias $path_alias = url($path, array('absolute' => FALSE)); + //strip base path from url + if ($base_path != '/') { + $path_alias = implode('/', array_diff_assoc(array_filter(explode('/', $path_alias)), array_filter(explode('/', $base_path)))); + } + #path redirects if (module_exists('path_redirect')){ $path_redirects = boost_path_redirect_load(array('redirect' => $path)); } - + #flush caches boost_cache_expire($path_alias, $wildcard); if (isset($path_redirects)) { @@ -549,8 +561,9 @@ function boost_cache_expire_derivative($ * matching a wildcard. */ function boost_cache_expire($path, $wildcard = FALSE) { - $filenames = array(); - $filenames = glob(boost_file_path($path, FALSE, FALSE) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT); + $tempA = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT); + $tempB = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_XML_EXTENSION, GLOB_NOSORT); + $filenames = array_filter($tempA + $tempB); if (empty($filenames)) { return FALSE; } @@ -582,7 +595,7 @@ function boost_cache_get($path) { /** * Replaces the cached contents of the specified page, if stale. */ -function boost_cache_set($path, $data = '') { +function boost_cache_set($path, $data = '', $extension = BOOST_FILE_EXTENSION) { // Append the Boost footer with the relevant timestamps $time = time(); $cached_at = date('Y-m-d H:i:s', $time); @@ -603,7 +616,7 @@ function boost_cache_set($path, $data = db_set_active(); // Create or update the static files as needed - if (($filename = boost_file_path($path))) { + if (($filename = boost_file_path($path, TRUE, $extension))) { boost_cache_write($filename, $data); if (BOOST_GZIP) { boost_cache_write(str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename). '.gz', gzencode($data,9)); @@ -669,7 +682,7 @@ function boost_cache_directory($host = N * $extension * add extension to end of filename */ -function boost_file_path($path, $query = TRUE, $extension = TRUE) { +function boost_file_path($path, $query = TRUE, $extension = BOOST_FILE_EXTENSION) { //handling of url variables if ($GLOBALS['_boost_query'] != '_') { if ($query) { @@ -697,7 +710,7 @@ function boost_file_path($path, $query = } } - return implode('/', array(BOOST_FILE_PATH, $path . (($extension) ? BOOST_FILE_EXTENSION : ''))); + return implode('/', array(BOOST_FILE_PATH, $path . (is_null($extension) ? '' : $extension))); } /**