You are here

function boost_cache_kill_url in Boost 6

Deletes cached page from file system & database.

Parameters

array $urls: list of urls to remove from the boost cache

boolean $force_flush = TRUE: Override BOOST_EXPIRE_NO_FLUSH setting.

1 call to boost_cache_kill_url()
boost_redirect_handler in ./boost.module
Grabs drupal_goto requests via boost_exit and looks for redirects.

File

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

Code

function boost_cache_kill_url($urls, $force_flush = TRUE) {
  global $base_path;
  $files = array();
  foreach ($urls as $value) {
    $decoded = urldecode($value);
    if ($decoded != $value) {
      $urls[] = $decoded;
    }
    $raw = rawurldecode($value);
    if ($raw != $decoded) {
      $urls[] = $decoded;
    }
  }
  $urls = array_unique($urls);
  $hashes = array_map('md5', $urls);
  $parts = array_map('parse_url', $urls);
  foreach ($parts as $part) {
    $files[]['filename'] = boost_file_path(ltrim($part['path'], $base_path), TRUE, BOOST_FILE_EXTENSION);
  }
  $result = boost_db_multi_select_in('boost_cache', 'hash_url', "'%s'", $hashes);
  while ($row = db_fetch_array($result)) {
    $files[] = array(
      'filename' => $row['filename'],
      'hash' => $row['hash'],
    );
  }
  if (!empty($files)) {
    boost_cache_kill($files, $force_flush);
    boost_remove_db($files);
    return TRUE;
  }
  else {
    return FALSE;
  }
}