You are here

function boost_cache_expire_by_filename in Boost 6

Expires the static file cache for paths matching a wildcard via filesystem.

Parameters

$path: Array of URLs

$wildcard: If true get all chached files that start with this path.

$force_flush: If true kill file no matter what.

1 call to boost_cache_expire_by_filename()
boost_cache_expire_derivative in ./boost.module
Finds all possible paths/redirects/aliases given the root path.

File

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

Code

function boost_cache_expire_by_filename($paths, $wildcard = TRUE, $force_flush, $debug = FALSE) {
  $filenames = array();
  if (empty($paths)) {
    return FALSE;
  }
  foreach ($paths as $path) {

    // Sanity check
    if (boost_file_path($path, FALSE) === FALSE) {
      continue;
    }

    // Get list of related files
    $html = glob(boost_file_path($path, FALSE, NULL) . ($wildcard ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT);
    $xml = glob(boost_file_path($path, FALSE, NULL) . ($wildcard ? '*' : '') . BOOST_XML_EXTENSION, GLOB_NOSORT);
    $json = glob(boost_file_path($path, FALSE, NULL) . ($wildcard ? '*' : '') . BOOST_JSON_EXTENSION, GLOB_NOSORT);

    // Make sure something is in the arrays
    $html[] = '';
    $xml[] = '';
    $json[] = '';

    // Merge arrays
    $filenames = array_filter(array_merge($filenames, $html, $xml, $json));
  }

  // Remove double slash from filename if it exists.
  foreach ($filenames as $key => $filename) {
    $filenames[$key] = implode('/', array_filter(explode('/', $filename)));
  }

  // Flush expired files
  if (!$debug) {
    boost_cache_flush_by_filename($filenames, $force_flush);
  }
  else {
    return $filenames;
  }
}