summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Carper2009-10-18 08:16:27 (GMT)
committer Mike Carper2009-10-18 08:16:27 (GMT)
commit62e56b926a2f05f6a53e943c1287651270a309b5 (patch)
tree4b1e909084d62a4891478cd98d8f398cd9e65f53
parent9661f9d1caa18baab649a78d8baa4183041baaf1 (diff)
#604390: Option for cron expire to work on singe db multisite setups.
-rw-r--r--boost.admin.inc6
-rw-r--r--boost.module38
2 files changed, 31 insertions, 13 deletions
diff --git a/boost.admin.inc b/boost.admin.inc
index 7831f88..fc251b0 100644
--- a/boost.admin.inc
+++ b/boost.admin.inc
@@ -383,6 +383,12 @@ function boost_admin_boost_performance_page() {
'#default_value' => BOOST_ONLY_ASCII_PATH,
'#description' => t('Only allowing ACSII characters is a safe way to cache pages. It severely limits i18n support so this can be turned off. Fair warning, disabling this may cause "page not found" errors depending on your url structure (spaces are bad, ect...). If you follow RFC 3986 you should be ok.'),
);
+ $form['advanced']['boost_flush_all_multisite'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Flush all sites caches in this database (singe db, multisite).'),
+ '#default_value' => BOOST_FLUSH_ALL_MULTISITE,
+ '#description' => t('This will flush/expire all cached files stored in this database, instead of only being specific to this site. Useful for i18n sites. You need to setup a separate cron call for each database (in your multisite install) either way though. This covers shared database usage; or place the boost tables into the a shared database, to have this setting work in a multiple database environment.'),
+ );
$form['advanced']['boost_asynchronous_output'] = array(
'#type' => 'checkbox',
'#title' => t('Asynchronous Operation: output HTML, close connection, then store static file.'),
diff --git a/boost.module b/boost.module
index 361dbf6..5df8607 100644
--- a/boost.module
+++ b/boost.module
@@ -58,6 +58,7 @@ define('BOOST_MAX_PATH_DEPTH', 10);
// Advanced Settings
define('BOOST_CHECK_BEFORE_CRON_EXPIRE', variable_get('boost_check_before_cron_expire', FALSE));
define('BOOST_PRE_PROCESS_FUNCTION', variable_get('boost_pre_process_function', ''));
+define('BOOST_FLUSH_ALL_MULTISITE', variable_get('boost_flush_all_multisite', FALSE));
define('BOOST_ONLY_ASCII_PATH', variable_get('boost_only_ascii_path', TRUE));
define('BOOST_ASYNCHRONOUS_OUTPUT', variable_get('boost_asynchronous_output', TRUE));
define('BOOST_FLUSH_DIR', variable_get('boost_flush_dir', TRUE));
@@ -1372,15 +1373,15 @@ function boost_cache_expire_router($router_items, $force_flush = FALSE) {
foreach ($router_items as $dblookup) {
if (isset($dblookup['base_dir'])) {
if (isset($dblookup['page_id'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
}
elseif (isset($dblookup['page_type'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type']);
db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_type = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_type']);
}
elseif (isset($dblookup['page_callback'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s'", $dblookup['base_dir'], $dblookup['page_callback']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s'", $dblookup['base_dir'], $dblookup['page_callback']);
db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s'", $dblookup['base_dir'], $dblookup['page_callback']);
}
else {
@@ -1389,15 +1390,15 @@ function boost_cache_expire_router($router_items, $force_flush = FALSE) {
}
else {
if (isset($dblookup['page_id'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_type = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_type'], $dblookup['page_id']);
}
elseif (isset($dblookup['page_type'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s'", $dblookup['page_callback'], $dblookup['page_type']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_type = '%s'", $dblookup['page_callback'], $dblookup['page_type']);
db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_type = '%s'", $dblookup['page_callback'], $dblookup['page_type']);
}
elseif (isset($dblookup['page_callback'])) {
- $result = db_query("SELECT filename, hash FROM {boost_cache} WHERE page_callback = '%s'", $dblookup['page_callback']);
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s'", $dblookup['page_callback']);
db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s'", $dblookup['page_callback']);
}
else {
@@ -1407,7 +1408,7 @@ function boost_cache_expire_router($router_items, $force_flush = FALSE) {
while ($info = db_fetch_array($result)) {
// Flush matching files
- boost_cache_kill($info['filename'], $info['hash'], $force_flush);
+ boost_cache_kill($info['filename'], $info['hash'], $force_flush, $info['base_dir']);
$count++;
}
}
@@ -1423,9 +1424,14 @@ function boost_cache_expire_router($router_items, $force_flush = FALSE) {
* Primary key in database; filename hash
* @param $force_flush
* Override BOOST_EXPIRE_NO_FLUSH setting
- */
-function boost_cache_kill($filename, $hash = '', $force_flush = FALSE) {
- if (variable_get('boost_ignore_flush', 0) < 3 && strstr($filename, BOOST_FILE_PATH)) {
+ * @param $base_dir
+ * Base directory of site
+ */
+function boost_cache_kill($filename, $hash = '', $force_flush = FALSE, $base_dir = '') {
+ // If not ignoring file removal
+ // AND site is multisite and cache path matches filename
+ // OR full base url matches filename
+ if (variable_get('boost_ignore_flush', 0) < 3 && ((BOOST_FLUSH_ALL_MULTISITE && strstr($filename, BOOST_ROOT_CACHE_DIR)) || strstr($filename, BOOST_FILE_PATH))) {
if ($hash == '') {
$hash = md5($filename);
}
@@ -1438,7 +1444,8 @@ function boost_cache_kill($filename, $hash = '', $force_flush = FALSE) {
if (file_exists($filename)) {
@unlink($filename);
}
- $gz_filename = str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename) . BOOST_GZIP_EXTENSION;
+ $base_dir = $base_dir == '' ? BOOST_FILE_PATH : $base_dir;
+ $gz_filename = str_replace($base_dir, BOOST_GZIP_FILE_PATH, $filename) . BOOST_GZIP_EXTENSION;
if (file_exists($gz_filename)) {
@unlink($gz_filename);
}
@@ -1454,9 +1461,14 @@ function boost_cache_kill($filename, $hash = '', $force_flush = FALSE) {
*/
function boost_cache_db_expire() {
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);
+ if (BOOST_FLUSH_ALL_MULTISITE) {
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE expire BETWEEN 1 AND %d", BOOST_TIME);
+ }
+ else {
+ $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND expire BETWEEN 1 AND %d", BOOST_FILE_PATH, BOOST_TIME);
+ }
while ($boost = db_fetch_array($result)) {
- boost_cache_kill($boost['filename'], $boost['hash'], TRUE);
+ boost_cache_kill($boost['filename'], $boost['hash'], TRUE, $boost['base_dir']);
}
if (BOOST_FLUSH_DIR) {
// TO-DO: del empty dirs.