You are here

function boost_cache_expire_router in Boost 6

Expires the static file cache for the given router items.

Parameters

$router_items: Array of $router_item array "objects" ['page_callback'] ['page_type'] ['page_id'] ['base_dir']

$force_flush: Override BOOST_EXPIRE_NO_FLUSH setting

$remove_from_db: Remove this entry from the boost-cache table.

$debug: Do nothing but return what would have been expired.

8 calls to boost_cache_expire_router()
boost_block_db_rm_settings_form_submit in ./boost.module
Removes page specific settings in the boost cache database.
boost_block_form_flush_submit in ./boost.module
boost_cache_expire_by_db in ./boost.module
Expires the static file cache for the given paths via database.
boost_expire_node in ./boost.module
Expires a node from the cache; including related pages.
boost_nodeapi in ./boost.module
Implementation of hook_nodeapi(). Acts on nodes defined by other modules.

... See full list

1 string reference to 'boost_cache_expire_router'
boost.module in ./boost.module
Provides static file caching for Drupal text output. Pages, Feeds, ect...

File

./boost.module, line 3402
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_cache_expire_router($router_items, $force_flush = FALSE, $remove_from_db = FALSE, $debug = FALSE) {

  // Get filenames & hash from db
  if (!is_array($router_items)) {
    return FALSE;
  }
  global $_boost;
  $count = 0;
  $files = $list = array();
  foreach ($router_items as $dblookup) {
    if (isset($dblookup['base_dir'])) {
      if (isset($dblookup['page_id']) && isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
        $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']);
        if (!$debug) {
          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_id']) && isset($dblookup['page_callback'])) {
        $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_id']);
        if (!$debug) {
          db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s' AND page_id = '%s'", $dblookup['base_dir'], $dblookup['page_callback'], $dblookup['page_id']);
        }
      }
      elseif (isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
        $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']);
        if (!$debug) {
          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, base_dir FROM {boost_cache} WHERE base_dir = '%s' AND page_callback = '%s'", $dblookup['base_dir'], $dblookup['page_callback']);
        if (!$debug) {
          db_query("DELETE FROM {boost_cache_relationships} WHERE base_dir = '%s' AND page_callback = '%s'", $dblookup['base_dir'], $dblookup['page_callback']);
        }
      }
      else {
        continue;
      }
    }
    else {
      if (isset($dblookup['page_id']) && isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
        $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']);
        if (!$debug) {
          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_id']) && isset($dblookup['page_callback'])) {
        $result = db_query("SELECT filename, hash, base_dir FROM {boost_cache} WHERE page_callback = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_id']);
        if (!$debug) {
          db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s' AND page_id = '%s'", $dblookup['page_callback'], $dblookup['page_id']);
        }
      }
      elseif (isset($dblookup['page_type']) && isset($dblookup['page_callback'])) {
        $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']);
        if (!$debug) {
          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, base_dir FROM {boost_cache} WHERE page_callback = '%s'", $dblookup['page_callback']);
        if (!$debug) {
          db_query("DELETE FROM {boost_cache_relationships} WHERE page_callback = '%s'", $dblookup['page_callback']);
        }
      }
      else {
        continue;
      }
    }
    while ($info = db_fetch_array($result)) {
      if (stristr($info['filename'], '#')) {
        continue;
      }
      $files[$info['hash']] = $info;
      if (BOOST_VERBOSE >= 9 && isset($_boost['verbose_option_selected']['boost_cache_expire_router'])) {
        $list[] = $info['filename'];
      }
    }
  }
  if (!$debug) {
    if (count($files)) {
      $count = boost_cache_kill($files, $force_flush);
      if ($remove_from_db) {
        boost_remove_db($files);
      }
    }
    if (BOOST_VERBOSE >= 9 && isset($_boost['verbose_option_selected']['boost_cache_expire_router'])) {
      watchdog('boost', 'Debug: boost_cache_expire_router() <br />Following files where flushed: <br />!list<br /><br />Input: <br /> !input <br />Files: !files', array(
        '!list' => implode('<br />', $list),
        '!input' => boost_print_r($router_items, TRUE, TRUE),
        '!files' => boost_print_r($files, TRUE, TRUE),
      ));
    }
    return $count;
  }
  else {
    return $files;
  }
}