'-1'"); while ($r = db_fetch_object($result)) { if (module_exists($r->module)) { $refresh = variable_get('bc_refresh_'. $r->module .'_'. $r->delta, array()); if ($refresh[$type] === $type) { $relate = variable_get('bc_relate_'. $r->module .'_'. $r->delta, array()); if ($relatednodetype == 'user_actions' || (is_array($relate) && $relate[$relatednodetype] === $relatednodetype)) { db_query("DELETE FROM {cache_block} WHERE cid like '%s'", $r->module .':'. $r->delta .'%'); if ($debug) { $info[] = t('
- module: %mod, delta: %delta', array('%mod' => $r->module, '%delta' => $r->delta)); } } } } } // Implode and put together a LIKE query. if ($debug && !empty($info)) { drupal_set_message(t("Block re-cached: ". implode(' ', $info))); } global $theme_key, $base_url; // Get a list of all of the blocks that are configured to be recached if // node of this content type is added/updated/deleted if($relatednodetype) { $cached_blocks = db_query("SELECT REPLACE(name, 'bc_relate_','') AS block FROM {variable} WHERE name LIKE 'bc_relate_%%' AND value LIKE '%%%s%%'", $relatednodetype.'";s'); } else { if($type == 'relate' || $type == 'refresh') { $cached_blocks = db_query("SELECT REPLACE(name, 'bc_relate_','') AS block FROM {variable} WHERE name LIKE 'bc_relate_%%'"); } elseif($type == 'life') { // Find blocks that are old enough to be recached // To consolidate into one SQL statement, we're adding together the // re-cache length of time to the cache timestamp, and seeing if it's // greater than the current time. $cached_blocks = db_query("SELECT REPLACE(v.name, 'bc_relate_','') AS block FROM {variable} v INNER JOIN {cache_block} b ON b.cid LIKE CONCAT(REPLACE(REPLACE(v.name, 'bc_life_',''),'_',':'),'%%') AND UNIX_TIMESTAMP(NOW()) > b.created + SUBSTRING_INDEX(SUBSTRING_INDEX(v.value,'\"',-2),'\"',1)"); } else { } } while($cached_block = db_fetch_object($cached_blocks)) { if(substr($cached_block->block,0,6) == 'views_') { $delta = str_replace("views_","",$cached_block->block); $module = "views"; cache_clear_all($module.":".$delta.":".$theme_key.":en","cache_block"); } else { $delta = str_replace("block_","",$cached_block->block); $module = "block"; cache_clear_all($module.":".$delta.":".$theme_key.":en","cache_block"); } // Check for pages that use this block $block_pages = db_fetch_object(db_query("SELECT bid, visibility, pages FROM {blocks} WHERE module='%s' AND delta='%s'", $module, $delta)); // If visibility is 0, it shows on all pages if($block_pages->visibility == 0) { cache_clear_all(); } elseif($block_pages->visibility == 1 && $block_pages->pages != "") { // Check every alias to see if it matches the block pages $paths = db_query("SELECT dst FROM {url_alias}"); while($path = db_fetch_object($paths)) { if(drupal_match_path($path->dst,$block_pages->pages)) { // It's a match, clear this pages cache cache_clear_all($base_url."/".$path->dst,"cache_page"); } } // Check for block insertions with this block-id $nodes = db_query("SELECT r.nid FROM {node_revisions} r INNER JOIN {node} n ON r.vid=n.vid INNER JOIN {content_type_page} p ON r.vid=p.vid WHERE r.body LIKE \"%[block-insertion block-id='%s'%\" OR p.field_side_column_value LIKE \"%[block-insertion block-id='%s'%\"", $block_pages->bid, $block_pages->bid); while($nid = db_result($nodes)) { $path = drupal_get_path_alias('node/'.$nid); cache_clear_all($base_url."/".$path,"cache_page"); } } } } ?>