diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 49692d9..beb726d 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -390,9 +390,7 @@ public function getCache($form_build_id, &$form_state) { * {@inheritdoc} */ public function setCache($form_build_id, $form, $form_state) { - // 6 hours cache life time for forms should be plenty. - $expire = 21600; - + $expire = \Drupal::config('system.performance')->get('cache.form.expire'); // Cache form structure. if (isset($form)) { if ($this->currentUser()->isAuthenticated()) { diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index 6b82e60..30d543b 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -195,6 +195,13 @@ system.performance: max_age: type: integer label: 'Max age of page cache' + form: + type: mapping + label: 'Form cache settings' + mapping: + expire: + type: integer + label: 'Form cache timeout' css: type: mapping label: 'CSS performance settings' diff --git a/core/modules/system/config/system.performance.yml b/core/modules/system/config/system.performance.yml index 29b434b..c006149 100644 --- a/core/modules/system/config/system.performance.yml +++ b/core/modules/system/config/system.performance.yml @@ -2,6 +2,8 @@ cache: page: use_internal: false max_age: 0 + form: + expire: 21600 css: preprocess: false gzip: true diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php index 0e6d629..9419f97 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php @@ -33,6 +33,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); $this->installSchema('system', array('key_value_expire')); + $this->installConfig(array('system')); $this->form_build_id = $this->randomName(); $this->form = array( diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index 487f4c8..2637640 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -41,6 +41,7 @@ public function setUp() { $container = new ContainerBuilder(); $container->set('url_generator', $this->urlGenerator); + $container->set('config.factory', $this->getConfigFactoryStub(array())); \Drupal::setContainer($container); }