Issue #1798724 by andreiashu, Albert Volkman, alexpott: Convert drupal_js_cache_files() to State system.
parent
0bba5d0643
commit
fa38430066
|
@ -4720,7 +4720,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
|
||||||
function drupal_build_js_cache($files) {
|
function drupal_build_js_cache($files) {
|
||||||
$contents = '';
|
$contents = '';
|
||||||
$uri = '';
|
$uri = '';
|
||||||
$map = variable_get('drupal_js_cache_files', array());
|
$map = state()->get('system.drupal_js_cache_files') ?: array();
|
||||||
// Create a new array so that only the file names are used to create the hash.
|
// Create a new array so that only the file names are used to create the hash.
|
||||||
// This prevents new aggregates from being created unnecessarily.
|
// This prevents new aggregates from being created unnecessarily.
|
||||||
$js_data = array();
|
$js_data = array();
|
||||||
|
@ -4765,7 +4765,7 @@ function drupal_build_js_cache($files) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$map[$key] = $uri;
|
$map[$key] = $uri;
|
||||||
variable_set('drupal_js_cache_files', $map);
|
state()->set('system.drupal_js_cache_files', $map);
|
||||||
}
|
}
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -4775,7 +4775,7 @@ function drupal_build_js_cache($files) {
|
||||||
*/
|
*/
|
||||||
function drupal_clear_js_cache() {
|
function drupal_clear_js_cache() {
|
||||||
state()->delete('system.javascript_parsed');
|
state()->delete('system.javascript_parsed');
|
||||||
variable_del('drupal_js_cache_files');
|
state()->delete('system.drupal_js_cache_files');
|
||||||
file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
|
file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -344,11 +344,11 @@ class JavaScriptTest extends WebTestBase {
|
||||||
));
|
));
|
||||||
|
|
||||||
// Store the expected key for the first item in the cache.
|
// Store the expected key for the first item in the cache.
|
||||||
$cache = array_keys(variable_get('drupal_js_cache_files', array()));
|
$cache = array_keys(state()->get('system.drupal_js_cache_files') ?: array());
|
||||||
$expected_key = $cache[0];
|
$expected_key = $cache[0];
|
||||||
|
|
||||||
// Reset variables and add a file in a different scope first.
|
// Reset variables and add a file in a different scope first.
|
||||||
variable_del('drupal_js_cache_files');
|
state()->delete('system.drupal_js_cache_files');
|
||||||
drupal_static_reset('drupal_add_js');
|
drupal_static_reset('drupal_add_js');
|
||||||
drupal_add_library('system', 'drupal');
|
drupal_add_library('system', 'drupal');
|
||||||
drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer'));
|
drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer'));
|
||||||
|
@ -363,7 +363,7 @@ class JavaScriptTest extends WebTestBase {
|
||||||
));
|
));
|
||||||
|
|
||||||
// Compare the expected key for the first file to the current one.
|
// Compare the expected key for the first file to the current one.
|
||||||
$cache = array_keys(variable_get('drupal_js_cache_files', array()));
|
$cache = array_keys(state()->get('system.drupal_js_cache_files') ?: array());
|
||||||
$key = $cache[0];
|
$key = $cache[0];
|
||||||
$this->assertEqual($key, $expected_key, 'JavaScript aggregation is not affected by ordering in different scopes.');
|
$this->assertEqual($key, $expected_key, 'JavaScript aggregation is not affected by ordering in different scopes.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2205,6 +2205,15 @@ function system_update_8031() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the drupal_js_cache_files variable.
|
||||||
|
*
|
||||||
|
* @ingroup config_upgrade
|
||||||
|
*/
|
||||||
|
function system_update_8032() {
|
||||||
|
update_variable_del('drupal_js_cache_files');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @} End of "defgroup updates-7.x-to-8.x".
|
* @} End of "defgroup updates-7.x-to-8.x".
|
||||||
* The next series of updates should start at 9000.
|
* The next series of updates should start at 9000.
|
||||||
|
|
Loading…
Reference in New Issue