Commit 17c3d258 authored by webchick's avatar webchick

Issue #1853086 by katbailey, msonnabaum, alexpott: Remove cache.page.enabled...

Issue #1853086 by katbailey, msonnabaum, alexpott: Remove cache.page.enabled in favor of an explicit internal cache setting.
parent 7e1a0ca0
......@@ -2328,7 +2328,7 @@ function _drupal_bootstrap_page_cache() {
else {
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
$config = config('system.performance');
$cache_enabled = $config->get('cache.page.enabled');
$cache_enabled = $config->get('cache.page.use_internal');
}
// If there is no session cookie and cache is enabled (or forced), try
// to serve a cached page.
......
......@@ -920,7 +920,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.page.enabled') && !empty($form_state['values']['form_build_id'])) {
if (!$config->get('cache.page.use_internal') && !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']);
}
......
......@@ -91,7 +91,8 @@ 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.page.enabled') && ($cache = drupal_page_set_cache($response->getContent()))) {
$max_age = config('system.performance')->get('cache.page.max_age');
if ($max_age > 0 && ($cache = drupal_page_set_cache($response->getContent()))) {
drupal_serve_page_from_cache($cache);
// drupal_serve_page_from_cache() already printed the response.
$response->setContent('');
......
......@@ -48,7 +48,8 @@ function setUp() {
// Enable page caching.
$config = config('system.performance');
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
// Enable access logging.
......
cache:
page:
enabled: '0'
use_internal: '0'
max_age: '0'
css:
preprocess: '0'
......
......@@ -35,7 +35,7 @@ public static function getInfo() {
function testHookExit() {
// Test with cache disabled. Exit should always fire.
$config = config('system.performance');
$config->set('cache.page.enabled', 0);
$config->set('cache.page.use_internal', 0);
$config->save();
$this->drupalGet('');
......@@ -44,7 +44,8 @@ function testHookExit() {
// Test with normal cache. On the first call, exit should fire
// (since cache is empty), but on the second call it should not be fired.
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
$this->drupalGet('');
$calls++;
......
......@@ -43,7 +43,8 @@ function setUp() {
*/
function testConditionalRequests() {
$config = config('system.performance');
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
// Fill the cache.
......@@ -87,14 +88,15 @@ function testConditionalRequests() {
*/
function testPageCache() {
$config = config('system.performance');
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
// Fill the cache.
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
$this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', 'Vary header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', 'Cache-Control header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=300', 'Cache-Control header was sent.');
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
......@@ -102,7 +104,7 @@ function testPageCache() {
$this->drupalGet('system-test/set-header', array('query' => array('name' => 'Foo', 'value' => 'bar')));
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
$this->assertEqual($this->drupalGetHeader('Vary'), 'Cookie,Accept-Encoding', 'Vary: Cookie header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=0', 'Cache-Control header was sent.');
$this->assertEqual($this->drupalGetHeader('Cache-Control'), 'public, max-age=300', 'Cache-Control header was sent.');
$this->assertEqual($this->drupalGetHeader('Expires'), 'Sun, 19 Nov 1978 05:00:00 GMT', 'Expires header was sent.');
$this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.');
......@@ -133,7 +135,8 @@ function testPageCache() {
*/
function testPageCompression() {
$config = config('system.performance');
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
// Fill the cache and verify that output is compressed.
......
......@@ -148,7 +148,8 @@ function testEmptyAnonymousSession() {
// The same behavior is expected when caching is enabled.
$config = config('system.performance');
$config->set('cache.page.enabled', 1);
$config->set('cache.page.use_internal', 1);
$config->set('cache.page.max_age', 300);
$config->save();
$this->drupalGet('');
$this->assertSessionCookie(FALSE);
......
......@@ -50,7 +50,7 @@ public function testVariableUpgrade() {
);
$expected_config['system.performance'] = array(
'cache.page.enabled' => '1',
'cache.page.use_internal' => '1',
'cache.page.max_age' => '1800',
'response.gzip' => '1',
'js.preprocess' => '1',
......
......@@ -1651,21 +1651,21 @@ function system_performance_settings($form, &$form_state) {
'#title' => t('Caching'),
);
$form['caching']['cache'] = array(
'#type' => 'checkbox',
'#title' => t('Cache pages for anonymous users'),
'#default_value' => $config->get('cache.page.enabled'),
'#weight' => -2,
);
$period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
$period[0] = '<' . t('none') . '>';
$form['caching']['page_cache_maximum_age'] = array(
'#type' => 'select',
'#title' => t('Expiration of cached pages'),
'#title' => t('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.'),
'#description' => t('The maximum time a page can be cached. This is used as the value for max-age in Cache-Control headers.'),
);
$form['caching']['cache'] = array(
'#type' => 'checkbox',
'#title' => t('Use internal page cache'),
'#description' => t("If a reverse proxy cache isn't available, use Drupal's internal cache system to store cached pages."),
'#default_value' => $config->get('cache.page.use_internal'),
);
$directory = 'public://';
......@@ -1682,7 +1682,7 @@ 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.page.enabled') ? '' : ' class="js-hide"';
$js_hide = ($config->get('cache.page.max_age') > 0) ? '' : ' class="js-hide"';
$form['bandwidth_optimization']['page_compression'] = array(
'#type' => 'checkbox',
'#title' => t('Compress cached pages.'),
......@@ -1724,7 +1724,7 @@ function system_performance_settings($form, &$form_state) {
function system_performance_settings_submit($form, &$form_state) {
config_context_enter('config.context.free');
$config = config('system.performance');
$config->set('cache.page.enabled', $form_state['values']['cache']);
$config->set('cache.page.use_internal', $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('css.preprocess', $form_state['values']['preprocess_css']);
......
......@@ -1585,7 +1585,7 @@ function system_update_8016() {
*/
function system_update_8017() {
update_variables_to_config('system.performance', array(
'cache' => 'cache.page.enabled',
'cache' => 'cache.page.use_internal',
'page_cache_maximum_age' => 'cache.page.max_age',
'page_compression' => 'response.gzip',
'preprocess_css' => 'css.preprocess',
......
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