Commit 5c8cdca2 authored by webchick's avatar webchick

Issue #1669902 by alexpott, aspilicious, sun: Adjust system.performance...

Issue #1669902 by alexpott, aspilicious, sun: Adjust system.performance configuration for new guidelines.
parent 4aaeaf52
......@@ -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
......
......@@ -2941,7 +2941,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.
......@@ -4213,7 +4213,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) {
......@@ -5004,7 +5004,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);
......
......@@ -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']);
}
......
......@@ -71,7 +71,7 @@ public function onRespond(FilterResponseEvent $event) {
// use partial page caching more extensively.
// Commit the user session, if needed.
drupal_session_commit();
if (config('system.performance')->get('cache') && ($cache = drupal_page_set_cache($response->getContent()))) {
if (config('system.performance')->get('cache.page.enabled') && ($cache = drupal_page_set_cache($response->getContent()))) {
drupal_serve_page_from_cache($cache);
// drupal_serve_page_from_cache() already printed the response.
$response->setContent('');
......
......@@ -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('preprocess.css', 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('preprocess.css', 0);
$config->save();
}
......
......@@ -33,7 +33,7 @@ function setUp() {
// 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.
......
......@@ -48,7 +48,7 @@ function setUp() {
// Enable page caching.
$config = config('system.performance');
$config->set('cache', 1);
$config->set('cache.page.enabled', 1);
$config->save();
// Enable access logging.
......
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'
......@@ -35,7 +35,7 @@ public static function getInfo() {
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 @@ function testHookBootExit() {
$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++;
......
......@@ -43,7 +43,7 @@ function setUp() {
*/
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 @@ function testConditionalRequests() {
*/
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 @@ function testPageCache() {
*/
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.
......
......@@ -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('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 @@ function setUp() {
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 @@ 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('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 @@ function testAggregation() {
*/
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.
......
......@@ -148,7 +148,7 @@ function testEmptyAnonymousSession() {
// 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);
......
......@@ -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('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 @@ 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('preprocess.css', 1);
$config->save();
$this->drupalGet('theme-test/suggestion');
$config->set('preprocess_css', 0);
$config->set('preprocess.css', 0);
$config->save();
}
......
......@@ -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' => '<div id="page-compression-wrapper"' . $js_hide . '>',
'#suffix' => '</div>',
);
$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();
}
......
......@@ -2046,6 +2046,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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment