diff --git a/core/includes/common.inc b/core/includes/common.inc index 09ac4ae48732b4409205b7cfde20913bd659c532..10b09d6f9737490d3be92b0aeb404838e610f400 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2818,7 +2818,7 @@ function drupal_aggregate_css(&$css_groups) { } else { $config = config('system.performance'); - $preprocess_css = $config->get('preprocess.css'); + $preprocess_css = $config->get('css.preprocess'); } // For each group that needs aggregation, aggregate its items. @@ -3152,9 +3152,9 @@ function drupal_build_css_cache($css) { // It's possible that the rewrite rules in .htaccess aren't working on this // server, but there's no harm (other than the time spent generating the // file) in generating the file anyway. Sites on servers where rewrite rules - // aren't working can set css_gzip_compression to FALSE in order to skip + // aren't working can set css.gzip to FALSE in order to skip // generating a file that won't be used. - if (variable_get('css_gzip_compression', TRUE) && extension_loaded('zlib')) { + if (config('system.performance')->get('css.gzip') && extension_loaded('zlib')) { if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) { return FALSE; } @@ -3339,7 +3339,7 @@ function drupal_clear_css_cache() { */ function drupal_delete_file_if_stale($uri) { // Default stale file threshold is 30 days. - if (REQUEST_TIME - filemtime($uri) > config('system.performance')->get('preprocess.stale_file_threshold')) { + if (REQUEST_TIME - filemtime($uri) > config('system.performance')->get('stale_file_threshold')) { file_unmanaged_delete($uri); } } @@ -4095,7 +4095,7 @@ function drupal_aggregate_js(&$js_groups) { } else { $config = config('system.performance'); - $preprocess_js = $config->get('preprocess.js'); + $preprocess_js = $config->get('js.preprocess'); } if ($preprocess_js) { @@ -4664,9 +4664,9 @@ function drupal_build_js_cache($files) { // It's possible that the rewrite rules in .htaccess aren't working on this // server, but there's no harm (other than the time spent generating the // file) in generating the file anyway. Sites on servers where rewrite rules - // aren't working can set js_gzip_compression to FALSE in order to skip + // aren't working can set js.gzip to FALSE in order to skip // generating a file that won't be used. - if (variable_get('js_gzip_compression', TRUE) && extension_loaded('zlib')) { + if (config('system.performance')->get('js.gzip') && extension_loaded('zlib')) { if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($contents, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) { return FALSE; } diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php index 8902d4c0652f9bb2de2533b5450f52d29cb3bf0b..d1f3b1e4c100b3ad9f36cea854dd20797592185a 100644 --- a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php +++ b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php @@ -105,7 +105,7 @@ function _testColor($theme, $test_values) { // Test with aggregated CSS turned on. $config = config('system.performance'); - $config->set('preprocess.css', 1); + $config->set('css.preprocess', 1); $config->save(); $this->drupalGet('<front>'); $stylesheets = variable_get('drupal_css_cache_files', array()); @@ -114,7 +114,7 @@ function _testColor($theme, $test_values) { $stylesheet_content .= join("\n", file(drupal_realpath($uri))); } $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')'); - $config->set('preprocess.css', 0); + $config->set('css.preprocess', 0); $config->save(); } diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml index 74839213920b6918a6292b4701b9e992591c8c8b..efd50f19fa5f54b65595bf1d5eaee55b3fab2ef2 100644 --- a/core/modules/system/config/system.performance.yml +++ b/core/modules/system/config/system.performance.yml @@ -2,9 +2,12 @@ cache: page: enabled: '0' max_age: '0' -preprocess: - css: '0' - js: '0' - stale_file_threshold: '2592000' +css: + preprocess: '0' + gzip: '1' +js: + preprocess: '0' + gzip: '1' response: gzip: '0' +stale_file_threshold: '2592000' diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 7ce84cbf6418687e44a8d98c50f7da0e5d579aea..255ed28e0af6e4db6050b3d18f2ac4cc2b4b49e6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -39,8 +39,8 @@ function setUp() { // Disable preprocessing $config = config('system.performance'); - $this->preprocess_js = $config->get('preprocess.js'); - $config->set('preprocess.js', 0); + $this->preprocess_js = $config->get('js.preprocess'); + $config->set('js.preprocess', 0); $config->save(); // Reset drupal_add_js() and drupal_add_library() statics before each test. @@ -51,7 +51,7 @@ function setUp() { function tearDown() { // Restore configured value for JavaScript preprocessing. $config = config('system.performance'); - $config->set('preprocess.js', $this->preprocess_js); + $config->set('js.preprocess', $this->preprocess_js); $config->save(); parent::tearDown(); } @@ -119,7 +119,7 @@ function testAttributes() { */ function testAggregatedAttributes() { // Enable aggregation. - config('system.performance')->set('preprocess.js', 1)->save(); + config('system.performance')->set('js.preprocess', 1)->save(); $default_query_string = variable_get('css_js_query_string', '0'); @@ -311,7 +311,7 @@ function testAggregation() { // 'every_page' files, and one file is made for the others. drupal_static_reset('drupal_add_js'); $config = config('system.performance'); - $config->set('preprocess.js', 1); + $config->set('js.preprocess', 1); $config->save(); drupal_add_library('system', 'drupal'); drupal_add_js('core/misc/ajax.js'); @@ -332,7 +332,7 @@ function testAggregation() { */ function testAggregationOrder() { // Enable JavaScript aggregation. - config('system.performance')->set('preprocess.js', 1)->save(); + config('system.performance')->set('js.preprocess', 1)->save(); drupal_static_reset('drupal_add_js'); // Add two JavaScript files to the current request and build the cache. diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index f1308c5e46385660d900e743e99b4fb135c6ca0f..5267300f0695b240c9f3a670fd0867a0fef2d2c1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -112,7 +112,7 @@ function testCSSOverride() { // so it doesn't matter what page we get, as long as it is themed with the // test theme. First we test with CSS aggregation disabled. $config = config('system.performance'); - $config->set('preprocess.css', 0); + $config->set('css.preprocess', 0); $config->save(); $this->drupalGet('theme-test/suggestion'); $this->assertNoText('system.base.css', 'The theme\'s .info file is able to override a module CSS file from being added to the page.'); @@ -121,10 +121,10 @@ function testCSSOverride() { // triggered during drupal_build_css_cache() when a source file doesn't // exist. Then allow remaining tests to continue with aggregation disabled // by default. - $config->set('preprocess.css', 1); + $config->set('css.preprocess', 1); $config->save(); $this->drupalGet('theme-test/suggestion'); - $config->set('preprocess.css', 0); + $config->set('css.preprocess', 0); $config->save(); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php index 283765d51168561ded412b9727cda07c359bb0da..9aa4a1b4d7a722f9f37d20d4082175f90bb5fb79 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php @@ -53,8 +53,8 @@ public function testVariableUpgrade() { 'cache.page.enabled' => '1', 'cache.page.max_age' => '1800', 'response.gzip' => '1', - 'preprocess.js' => '1', - 'preprocess.css' => '1', + 'js.preprocess' => '1', + 'css.preprocess' => '1', ); $expected_config['system.rss'] = array( diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 46b4b9d399670cb7d4807ae2c611f223237f8aa7..b8cae7a86579dec4ba3f25fb5f896e482dd34bd8 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1664,13 +1664,13 @@ function system_performance_settings($form, &$form_state) { $form['bandwidth_optimization']['preprocess_css'] = array( '#type' => 'checkbox', '#title' => t('Aggregate and compress CSS files.'), - '#default_value' => $config->get('preprocess.css'), + '#default_value' => $config->get('css.preprocess'), '#disabled' => $disabled, ); $form['bandwidth_optimization']['preprocess_js'] = array( '#type' => 'checkbox', '#title' => t('Aggregate JavaScript files.'), - '#default_value' => $config->get('preprocess.js'), + '#default_value' => $config->get('js.preprocess'), '#disabled' => $disabled, ); @@ -1694,8 +1694,8 @@ function system_performance_settings_submit($form, &$form_state) { $config->set('cache.page.enabled', $form_state['values']['cache']); $config->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']); $config->set('response.gzip', $form_state['values']['page_compression']); - $config->set('preprocess.css', $form_state['values']['preprocess_css']); - $config->set('preprocess.js', $form_state['values']['preprocess_js']); + $config->set('css.preprocess', $form_state['values']['preprocess_css']); + $config->set('js.preprocess', $form_state['values']['preprocess_js']); $config->save(); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 5fb624a710fc01d2631c567fd65d2494f92f759a..be3a6d8b386d1f0444b3435ea3cbc00239bec682 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1940,9 +1940,9 @@ function system_update_8017() { 'cache' => 'cache.page.enabled', 'page_cache_maximum_age' => 'cache.page.max_age', 'page_compression' => 'response.gzip', - 'preprocess_css' => 'preprocess.css', - 'preprocess_js' => 'preprocess.js', - 'stale_file_threshold' => 'preprocess.stale_file_threshold', + 'preprocess_css' => 'css.preprocess', + 'preprocess_js' => 'js.preprocess', + 'stale_file_threshold' => 'stale_file_threshold', )); } @@ -2304,6 +2304,19 @@ function system_update_8039() { update_variables_to_config('system.site', $variable_map); } +/** + * Converts css and js gzip compression variables to config. + * + * @ingroup config_upgrade + */ +function system_update_8040() { + $variable_map = array( + 'css_gzip_compression' => 'css.gzip', + 'js_gzip_compression' => 'js.gzip' + ); + update_variables_to_config('system.performance', $variable_map); +} + /** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 20f449092fe13613a2b3ea100576f5c68a2afe0f..e0d69bd0aae73605ba7285fa89a740edfc469c37 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -458,8 +458,8 @@ * configured to cache and compress these files itself you may want to uncomment * one or both of the below lines, which will prevent gzip files being stored. */ -# $conf['css_gzip_compression'] = FALSE; -# $conf['js_gzip_compression'] = FALSE; +# $conf['system.performance']['css.gzip'] = FALSE; +# $conf['system.performance']['js.gzip'] = FALSE; /** * String overrides: