function _blockcache_alter_cleanup in Block Cache Alter 6
Same name and namespace in other branches
- 7 blockcache_alter.module \_blockcache_alter_cleanup()
Cleanup cached blocks if necessary.
Parameters
string $type operation type.:
string $relatednodetype Related node type (if available):
3 calls to _blockcache_alter_cleanup()
- blockcache_alter_comment in ./
blockcache_alter.module - Implementation of hook_comment().
- blockcache_alter_nodeapi in ./
blockcache_alter.module - Implementation of hook_nodeapi().
- blockcache_alter_user in ./
blockcache_alter.module - Implementation of hook_user().
File
- ./
blockcache_alter.module, line 375 - Block Cache alter.
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)) {
$placeholders = db_placeholders($modules, 'varchar');
$query = "SELECT module, delta FROM {blocks} WHERE (status = '1' OR module IN ({$placeholders})) AND cache <> '-1'";
$result = db_query($query, $modules);
}
else {
$query = "SELECT module, delta FROM {blocks} WHERE status = '1' AND cache <> '-1'";
$result = db_query($query);
}
while ($r = db_fetch_object($result)) {
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("Block re-cached: " . implode(' ', $info)));
}
}