summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2013-02-28 03:00:19 (GMT)
committerwebchick2013-02-28 03:00:19 (GMT)
commit17c3d258ed166a66ac6f4aae0fb17831b31dec35 (patch)
treeeeded56056dedb27ffd972ffb3ef6d415768bec3
parent7e1a0ca0bba94a66a60094b0dcd2e920545a4872 (diff)
Issue #1853086 by katbailey, msonnabaum, alexpott: Remove cache.page.enabled in favor of an explicit internal cache setting.
-rw-r--r--core/includes/bootstrap.inc2
-rw-r--r--core/includes/form.inc2
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php3
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php3
-rw-r--r--core/modules/system/config/system.performance.yml2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php5
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Bootstrap/PageCacheTest.php13
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php2
-rw-r--r--core/modules/system/system.admin.inc22
-rw-r--r--core/modules/system/system.install2
11 files changed, 33 insertions, 26 deletions
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 8fde8aa..0d07356 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -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.
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 7e37405..3ebaca1 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -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']);
}
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index f29e0b0..c5c491c 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -91,7 +91,8 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
// 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('');
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
index 4cb7053..286ad71 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
@@ -48,7 +48,8 @@ class StatisticsLoggingTest extends WebTestBase {
// 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.
diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml
index d508591..80f349a 100644
--- a/core/modules/system/config/system.performance.yml
+++ b/core/modules/system/config/system.performance.yml
@@ -1,6 +1,6 @@
cache:
page:
- enabled: '0'
+ use_internal: '0'
max_age: '0'
css:
preprocess: '0'
diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php
index 0673340..0a8ef18 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php
@@ -35,7 +35,7 @@ class HookExitTest extends WebTestBase {
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 @@ class HookExitTest extends WebTestBase {
// 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++;
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 92c0dce..c09576c 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,8 @@ class PageCacheTest extends WebTestBase {
*/
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 @@ class PageCacheTest extends WebTestBase {
*/
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 @@ class PageCacheTest extends WebTestBase {
$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 @@ class PageCacheTest extends WebTestBase {
*/
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.
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 dadd2f2..53a443e 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,8 @@ class SessionTest extends WebTestBase {
// 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);
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 7d0d29f..73a2977 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
@@ -50,7 +50,7 @@ class SystemUpgradePathTest extends UpgradePathTestBase {
);
$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',
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index f66fd2e..a2c7011 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -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']);
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index d8674bb..daac6ba 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -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',