diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e173a95..15d8245 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1289,7 +1289,7 @@ function drupal_serve_page_from_cache(stdClass $cache) { $config = config('system.performance'); // Negotiate whether to use compression. - $page_compression = $config->get('page_compression') && extension_loaded('zlib'); + $page_compression = $config->get('response.gzip') && extension_loaded('zlib'); $return_compressed = $page_compression && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE; // Get headers set in hook_boot(). Keys are lower-case. @@ -1315,7 +1315,7 @@ function drupal_serve_page_from_cache(stdClass $cache) { // max-age > 0, allowing the page to be cached by external proxies, when a // session cookie is present unless the Vary header has been replaced or // unset in hook_boot(). - $max_age = !isset($_COOKIE[session_name()]) || isset($hook_boot_headers['vary']) ? $config->get('page_cache_maximum_age') : 0; + $max_age = !isset($_COOKIE[session_name()]) || isset($hook_boot_headers['vary']) ? $config->get('cache.page.max_age') : 0; $default_headers['Cache-Control'] = 'public, max-age=' . $max_age; // Entity tag should change if the output changes. @@ -2268,7 +2268,7 @@ function _drupal_bootstrap_page_cache() { else { drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE); $config = config('system.performance'); - $cache_enabled = $config->get('cache'); + $cache_enabled = $config->get('cache.page.enabled'); } drupal_block_denied(ip_address()); // If there is no session cookie and cache is enabled (or forced), try diff --git a/core/includes/common.inc b/core/includes/common.inc index 17e1363..38c8985 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2935,7 +2935,7 @@ function drupal_aggregate_css(&$css_groups) { } else { $config = config('system.performance'); - $preprocess_css = $config->get('preprocess_css'); + $preprocess_css = $config->get('preprocess.css'); } // For each group that needs aggregation, aggregate its items. @@ -4207,7 +4207,7 @@ function drupal_aggregate_js(&$js_groups) { } else { $config = config('system.performance'); - $preprocess_js = $config->get('preprocess_js'); + $preprocess_js = $config->get('preprocess.js'); } if ($preprocess_js) { @@ -4998,7 +4998,7 @@ function drupal_page_set_cache($body) { } if ($cache->data['body']) { - if (config('system.performance')->get('page_compression') && extension_loaded('zlib')) { + if (config('system.performance')->get('response.gzip') && extension_loaded('zlib')) { $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP); } cache('page')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); diff --git a/core/includes/form.inc b/core/includes/form.inc index 9aa8be9..362d0d5 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -879,7 +879,7 @@ function drupal_process_form($form_id, &$form, &$form_state) { // here, as we've finished with them. The in-memory copies are still // here, though. $config = config('system.performance'); - if (!$config->get('cache') && !empty($form_state['values']['form_build_id'])) { + if (!$config->get('cache.page.enabled') && !empty($form_state['values']['form_build_id'])) { cache('form')->delete('form_' . $form_state['values']['form_build_id']); cache('form')->delete('form_state_' . $form_state['values']['form_build_id']); } diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php index 3a46916..8902d4c 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 @@ class ColorTest extends WebTestBase { // Test with aggregated CSS turned on. $config = config('system.performance'); - $config->set('preprocess_css', 1); + $config->set('preprocess.css', 1); $config->save(); $this->drupalGet(''); $stylesheets = variable_get('drupal_css_cache_files', array()); @@ -114,7 +114,7 @@ class ColorTest extends WebTestBase { $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('preprocess.css', 0); $config->save(); } diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php index 9357331..61e83c0 100644 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php +++ b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php @@ -33,7 +33,7 @@ class PollVoteCheckHostnameTest extends PollTestBase { // Enable page cache to verify that the result page is not saved in the // cache when anonymous voting is allowed. $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); // Create poll. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php index cb0a08e..7526afb 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php @@ -48,7 +48,7 @@ class StatisticsLoggingTest extends WebTestBase { // Enable page caching. $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); // Enable access logging. diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml index 8629f75..f73c09f 100644 --- a/core/modules/system/config/system.performance.yml +++ b/core/modules/system/config/system.performance.yml @@ -1,5 +1,9 @@ -cache: '0' -page_cache_maximum_age: '0' -page_compression: '1' -preprocess_css: '0' -preprocess_js: '0' +cache: + page: + enabled: '0' + max_age: '0' +preprocess: + css: '0' + js: '0' +response: + gzip: '0' diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php index e75dada..3c43487 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php @@ -35,7 +35,7 @@ class HookBootExitTest extends WebTestBase { function testHookBootExit() { // Test with cache disabled. Boot and exit should always fire. $config = config('system.performance'); - $config->set('cache', 0); + $config->set('cache.page.enabled', 0); $config->save(); $this->drupalGet(''); @@ -44,7 +44,7 @@ class HookBootExitTest extends WebTestBase { $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with disabled cache.')); // Test with normal cache. Boot and exit should be called. - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); $this->drupalGet(''); $calls++; diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php index 91543b9..d4c1a3b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php @@ -43,7 +43,7 @@ class PageCacheTest extends WebTestBase { */ function testConditionalRequests() { $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); // Fill the cache. @@ -87,7 +87,7 @@ class PageCacheTest extends WebTestBase { */ function testPageCache() { $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); // Fill the cache. @@ -133,7 +133,7 @@ class PageCacheTest extends WebTestBase { */ function testPageCompression() { $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); // Fill the cache and verify that output is compressed. 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 1b07174..b43e3fb 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 @@ class JavaScriptTest extends WebTestBase { // Disable preprocessing $config = config('system.performance'); - $this->preprocess_js = $config->get('preprocess_js'); - $config->set('preprocess_js', 0); + $this->preprocess_js = $config->get('preprocess.js'); + $config->set('preprocess.js', 0); $config->save(); // Reset drupal_add_js() and drupal_add_library() statics before each test. @@ -51,7 +51,7 @@ class JavaScriptTest extends WebTestBase { function tearDown() { // Restore configured value for JavaScript preprocessing. $config = config('system.performance'); - $config->set('preprocess_js', $this->preprocess_js); + $config->set('preprocess.js', $this->preprocess_js); $config->save(); parent::tearDown(); } @@ -300,7 +300,7 @@ class JavaScriptTest extends WebTestBase { // '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('preprocess.js', 1); $config->save(); drupal_add_js('core/misc/ajax.js'); drupal_add_js('core/misc/collapse.js', array('every_page' => TRUE)); @@ -320,7 +320,7 @@ class JavaScriptTest extends WebTestBase { */ function testAggregationOrder() { // Enable JavaScript aggregation. - config('system.performance')->set('preprocess_js', 1)->save(); + config('system.performance')->set('preprocess.js', 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/Session/SessionTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php index 1a523e4..0abefb5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php @@ -148,7 +148,7 @@ class SessionTest extends WebTestBase { // The same behavior is expected when caching is enabled. $config = config('system.performance'); - $config->set('cache', 1); + $config->set('cache.page.enabled', 1); $config->save(); $this->drupalGet(''); $this->assertSessionCookie(FALSE); 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 29bfee1..484d00b 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 @@ class ThemeTest extends WebTestBase { // 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('preprocess.css', 0); $config->save(); $this->drupalGet('theme-test/suggestion'); $this->assertNoText('system.base.css', t('The theme\'s .info file is able to override a module CSS file from being added to the page.')); @@ -121,10 +121,10 @@ class ThemeTest extends WebTestBase { // 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('preprocess.css', 1); $config->save(); $this->drupalGet('theme-test/suggestion'); - $config->set('preprocess_css', 0); + $config->set('preprocess.css', 0); $config->save(); } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 8aa3ed4..72c50d4 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1718,7 +1718,7 @@ function system_performance_settings($form, &$form_state) { $form['caching']['cache'] = array( '#type' => 'checkbox', '#title' => t('Cache pages for anonymous users'), - '#default_value' => $config->get('cache'), + '#default_value' => $config->get('cache.page.enabled'), '#weight' => -2, ); @@ -1727,7 +1727,7 @@ function system_performance_settings($form, &$form_state) { $form['caching']['page_cache_maximum_age'] = array( '#type' => 'select', '#title' => t('Expiration of cached pages'), - '#default_value' => $config->get('page_cache_maximum_age'), + '#default_value' => $config->get('cache.page.max_age'), '#options' => $period, '#description' => t('The maximum time an external cache can use an old version of a page.'), ); @@ -1746,24 +1746,24 @@ function system_performance_settings($form, &$form_state) { '#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message, ); - $js_hide = $config->get('cache') ? '' : ' class="js-hide"'; + $js_hide = $config->get('cache.page.enabled') ? '' : ' class="js-hide"'; $form['bandwidth_optimization']['page_compression'] = array( '#type' => 'checkbox', '#title' => t('Compress cached pages.'), - '#default_value' => $config->get('page_compression'), + '#default_value' => $config->get('response.gzip'), '#prefix' => '
', '#suffix' => '
', ); $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('preprocess.css'), '#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('preprocess.js'), '#disabled' => $disabled, ); @@ -1784,11 +1784,11 @@ function system_performance_settings($form, &$form_state) { */ function system_performance_settings_submit($form, &$form_state) { $config = config('system.performance'); - $config->set('cache', $form_state['values']['cache']); - $config->set('page_cache_maximum_age', $form_state['values']['page_cache_maximum_age']); - $config->set('page_compression', $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('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->save(); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0e42214..b8d402c 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2047,6 +2047,21 @@ function system_update_8016() { } /** + * Moves system performance settings from variable to config. + * + * @ingroup config_upgrade + */ +function system_update_8017() { + update_variables_to_config('system.site', array( + 'cache' => 'cache.page.enabled', + 'page_cache_maximum_age' => 'cache.page.max_age', + 'page_compression' => 'response.gzip', + 'preprocess_css' => 'preprocess.css', + 'preprocess_js' => 'preprocess.js', + )); +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */