diff --git a/core/includes/common.inc b/core/includes/common.inc index 9601c76..52c5bfa 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3425,7 +3425,8 @@ function drupal_clear_css_cache() { */ function drupal_delete_file_if_stale($uri) { // Default stale file threshold is 30 days. - if (REQUEST_TIME - filemtime($uri) > variable_get('drupal_stale_file_threshold', 2592000)) { + $threshold = state()->get('system.stale_file_threshold') ?: 2592000; + if (REQUEST_TIME - filemtime($uri) > $threshold) { file_unmanaged_delete($uri); } } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index e938128..34a598f 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2215,6 +2215,25 @@ function system_update_8032() { } /** + * Converts common.inc variables to the state system. + * + * @ingroup state_upgrade + */ +function system_update_7033() { + // Old variable names as keys, new state names as values. + $variables = array( + 'drupal_stale_file_threshold' => 'system.stale_file_threshold', + ); + // Convert any saved variables to the state system. + foreach ($variables as $variable_name => $state_name) { + if ($value = update_variable_get($variable_name, FALSE)) { + state()->set($state_name, $value); + } + update_variable_del($variable_name); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */