You are here

function advagg_admin_flush_cache_button in Advanced CSS/JS Aggregation 7.2

Same name and namespace in other branches
  1. 6 advagg.admin.inc \advagg_admin_flush_cache_button()
  2. 7 includes/admin.inc \advagg_admin_flush_cache_button()

Perform a smart flush.

Related topics

2 calls to advagg_admin_flush_cache_button()
advagg_admin_flush_cache in ./advagg.module
Cache clear callback for admin_menu/flush-cache/advagg.
advagg_admin_reset_mtime in ./advagg.admin.inc
Clear out all advagg cache bins and increment the counter.
1 string reference to 'advagg_admin_flush_cache_button'
advagg_admin_operations_form in ./advagg.admin.inc
Form builder; Do advagg operations.

File

./advagg.admin.inc, line 1581
Admin page callbacks for the advanced CSS/JS aggregation module.

Code

function advagg_admin_flush_cache_button() {

  // Clear the libraries cache.
  if (function_exists('libraries_flush_caches')) {
    $cache_tables = libraries_flush_caches();
    foreach ($cache_tables as $table) {
      cache_clear_all('*', $table, TRUE);
    }
  }

  // Run the command.
  module_load_include('inc', 'advagg', 'advagg.cache');
  $flushed = advagg_push_new_changes();
  if (variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) >= 0) {

    // Display a simple message if not in Development mode.
    drupal_set_message(t('Advagg Cache Cleared'));
  }
  else {
    list($css_path) = advagg_get_root_files_dir();
    $parts_uri = $css_path[1] . '/parts';

    // Report back the results.
    foreach ($flushed as $filename => $data) {
      if (strpos($filename, $parts_uri) === 0) {

        // Do not report on css files manged in the parts directory.
        unset($flushed[$filename]);
        continue;
      }
      $ext = pathinfo($filename, PATHINFO_EXTENSION);
      drupal_set_message(t('The file %filename has changed. %db_usage aggregates are using this file. %db_count db cache entries and all %type full cache entries have been flushed from the cache bins. Trigger: <code>@changes</code>', array(
        '%filename' => $filename,
        '%db_usage' => $data[0],
        '%db_count' => $data[1],
        '@changes' => print_r($data[2], TRUE),
        '%type' => $ext,
      )));
    }
    if (empty($flushed)) {
      drupal_set_message(t('No changes found. Nothing was cleared.'));
      return;
    }
  }
}