function _blockcache_alter_cleanup in Block Cache Alter 7
Same name and namespace in other branches
- 6 blockcache_alter.module \_blockcache_alter_cleanup()
Cleanup cached blocks if necessary.
Parameters
string $type operation type.:
string $relatednodetype Related node type (if available):
11 calls to _blockcache_alter_cleanup()
- blockcache_alter_comment_delete in ./
blockcache_alter.module - Implementation of hook_comment_delete().
- blockcache_alter_comment_insert in ./
blockcache_alter.module - Implementation of hook_comment_insert().
- blockcache_alter_comment_update in ./
blockcache_alter.module - Implementation of hook_comment_update().
- blockcache_alter_node_delete in ./
blockcache_alter.module - Implementation of hook_node_delete().
- blockcache_alter_node_insert in ./
blockcache_alter.module - Implementation of hook_node_insert().
File
- ./
blockcache_alter.module, line 448 - Block cache alter module.
Code
function _blockcache_alter_cleanup($type, $relatednodetype = FALSE) {
$info = array();
$debug = variable_get('bca_debug', FALSE) && user_access('administer site configuration');
$modules = variable_get('blockcache_alter_include_modules', array());
if (!empty($modules)) {
$query = "SELECT module, delta FROM {block} WHERE (status = '1' OR module IN (:modules)) AND cache <> '-1'";
$result = db_query($query, $modules);
}
else {
$query = "SELECT module, delta FROM {block} WHERE status = '1' AND cache <> '-1'";
$result = db_query($query);
}
foreach ($result as $r) {
if (module_exists($r->module)) {
$refresh = variable_get('bc_refresh_' . $r->module . '_' . $r->delta, array());
if (isset($refresh[$type]) && $refresh[$type] === $type) {
$relate = variable_get('bc_relate_' . $r->module . '_' . $r->delta, array());
if ($relatednodetype == 'user_actions' || is_array($relate) && $relate[$relatednodetype] === $relatednodetype) {
cache_clear_all($r->module . ':' . $r->delta, 'cache_block', TRUE);
if ($debug) {
$info[] = t('<br /> - module: %mod, delta: %delta', array(
'%mod' => $r->module,
'%delta' => $r->delta,
));
}
}
}
}
}
// Let other modules cleanup more.
$hook = 'blockcache_alter_cleanup';
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
$function($type, $relatednodetype, $info);
}
// Implode and put together a LIKE query.
if ($debug && !empty($info)) {
drupal_set_message(t("DEBUG: Block re-cached: " . implode(' ', $info)));
}
}