Flush the correct caches so CSS/JS changes go live.
Return value
array Array of files that have changed and caches flushed.
7 calls to advagg_push_new_changes()
- advagg_admin_flush_cache_button dans ./
advagg.admin.inc - Perform a smart flush.
- advagg_advagg_changed_files dans ./
advagg.advagg.inc - Implements hook_advagg_changed_files().
- advagg_flush_caches dans ./
advagg.module - Implements hook_flush_caches().
- advagg_relocate_css_post_alter dans advagg_relocate/
advagg_relocate.module - Alter the css array.
- advagg_relocate_js_post_alter dans advagg_relocate/
advagg_relocate.module - Alter the js array.
1 string reference to 'advagg_push_new_changes'
- advagg_admin_clear_all_caches_button dans ./
advagg.admin.inc - Clear out all advagg cache bins.
Fichier
-
./
advagg.cache.inc, line 93
Code
function advagg_push_new_changes(array $files = array()) {
$results = array();
// Scan the file system for changes to CSS/JS files.
if (empty($files)) {
$files = advagg_scan_for_changes();
if (variable_get('advagg_debug', ADVAGG_DEBUG) >= 2) {
$variables = array(
'@files' => print_r($files, TRUE),
);
watchdog('advagg-debug', 'Changes detected in <pre>@files</pre>.', $variables, WATCHDOG_DEBUG);
}
}
// Clear some static caches.
drupal_static_reset('advagg_get_info_on_file');
drupal_static_reset('advagg_drupal_hash_base64');
drupal_static_reset('advagg_current_hooks_hash_array');
drupal_static_reset('advagg_get_current_hooks_hash');
if (variable_get('advagg_debug', ADVAGG_DEBUG) >= 2) {
// Exception used to get a compact stack trace.
$e = new Exception();
$variables = array(
'@changes' => print_r($e->getTraceAsString(), TRUE),
);
watchdog('advagg-debug', 'New changes called by: <pre>@changes</pre>', $variables, WATCHDOG_DEBUG);
}
// If something changed, flush the correct caches so that change goes out.
if (!empty($files)) {
$types = array();
module_load_include('inc', 'advagg', 'advagg');
foreach ($files as $filename => $meta_data) {
// Lookup the aggregates/cache ids that use this file.
$cache_ids = advagg_get_aggregates_using_file($meta_data['filename_hash'], TRUE);
$cache_hits = array();
$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$types[$ext] = TRUE;
if (!empty($cache_ids)) {
$cache_hits = cache_get_multiple($cache_ids, 'cache_advagg_info');
foreach ($cache_hits as $cid => $data) {
if (variable_get('advagg_debug', ADVAGG_DEBUG) >= 2) {
watchdog('advagg-debug', 'Clearing cache @cid.', array(
'@cid' => $cid,
), WATCHDOG_DEBUG);
}
cache_clear_all($cid, 'cache_advagg_info', FALSE);
}
}
$changes = array();
if (!empty($meta_data['changes'])) {
$changes = $meta_data['changes'];
unset($meta_data['changes']);
}
$results[$filename] = array(
count($cache_ids),
count($cache_hits),
$changes,
);
// Update database.
advagg_insert_update_files(array(
$filename => $meta_data,
), $ext);
}
// Change query-strings on css/js files to enforce reload for all users.
// Change css_js_query_string variable.
_drupal_flush_css_js();
// Let other modules know about the changed files.
// Call hook_advagg_changed_files().
module_invoke_all('advagg_changed_files', $files, $types);
// Clear out the full aggregates cache.
foreach ($types as $ext => $bool) {
if (variable_get('advagg_debug', ADVAGG_DEBUG) >= 2) {
$variables = array(
'@ext' => print_r($ext, TRUE),
);
watchdog('advagg-debug', 'Clearing cache advagg:@ext: in cache_advagg_aggregates.', $variables, WATCHDOG_DEBUG);
}
cache_clear_all('advagg:' . $ext . ':', 'cache_advagg_aggregates', TRUE);
}
}
// Return what was done.
return $results;
}