Will scan, flush, use, and report any changes to css/js files in aggregates.
1 call to advagg_scan_filesystem_for_changes_live()
- advagg_preprocess_page dans ./
advagg.module - Implements hook_preprocess_page().
Fichier
-
./
advagg.module, line 4842
Code
function advagg_scan_filesystem_for_changes_live() {
static $function_has_ran;
if (isset($function_has_ran)) {
return;
}
$function_has_ran = TRUE;
$bypass_cookie = FALSE;
$cookie_name = 'AdvAggDisabled';
$key = drupal_hmac_base64('advagg_cookie', drupal_get_private_key() . drupal_get_hash_salt() . variable_get('cron_key', 'drupal'));
if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] == $key) {
$bypass_cookie = TRUE;
}
if (!advagg_enabled() && !$bypass_cookie || variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) >= 0) {
return;
}
// Scan for changes to any CSS/JS files.
module_load_include('inc', 'advagg', 'advagg.cache');
$flushed = advagg_push_new_changes();
// Report back the results.
if (empty($flushed) || !user_is_logged_in()) {
return;
}
list($css_path) = advagg_get_root_files_dir();
$parts_uri = $css_path[1] . '/parts';
foreach ($flushed as $filename => $data) {
if (strpos($filename, $parts_uri) === 0) {
// Do not report on css files manged in the parts directory.
continue;
}
if (variable_get('advagg_show_file_changed_message', ADVAGG_SHOW_FILE_CHANGED_MESSAGE)) {
$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' => count($data[0]),
'%db_count' => count($data[1]),
'@changes' => print_r($data[2], TRUE),
'%type' => $ext,
)));
}
}
}