Skip to content

Instantly share code, notes, and snippets.

Created February 8, 2012 17:35
Show Gist options
  • Save anonymous/1771515 to your computer and use it in GitHub Desktop.
Save anonymous/1771515 to your computer and use it in GitHub Desktop.
Domain access find other cache bins
/**
* Implementation of hook_flush_caches().
*/
function calarts_domain_specific_customizations_flush_caches() {
if (!module_exists('domain')) {
return array();
}
global $db_url;
$connect_url = $db_url;
static $not_first_time;
if ($not_first_time) {
return array();
}
$connect_url = parse_url($connect_url);
$connect_path = substr($connect_url['path'], 1);
$not_first_time = TRUE;
$core = array('cache', 'cache_block', 'cache_filter', 'cache_page');
$cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
$new_cache_tables = array();
foreach ($cache_tables as $cache_table) {
// Until the db_table_exists issue is solved, use this method
if (db_fetch_object(db_query("SHOW TABLES FROM $connect_path LIKE '". db_escape_table($cache_table) ."'"))) {
$new_cache_tables[] = $connect_path .'.'. $cache_table;
}
}
$domains = domain_domains();
foreach ($domains as $domain_id => $domain_values) {
foreach ($cache_tables as $cache_table) {
$domain_table = 'domain_'. $domain_id .'_'. $cache_table;
if (db_table_exists($domain_table)) {
$new_cache_tables[] = $domain_table;
}
}
}
return $new_cache_tables;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment