diff --git a/core/lib/Drupal/Core/Form/FormCache.php b/core/lib/Drupal/Core/Form/FormCache.php index ea38fd2..621bfca 100644 --- a/core/lib/Drupal/Core/Form/FormCache.php +++ b/core/lib/Drupal/Core/Form/FormCache.php @@ -26,6 +26,14 @@ class FormCache implements FormCacheInterface { /** + * The default lifetime of the form's cache is set to 6 hours. + */ + const CACHE_LIFETIME = 21600; + + /** + * + */ + /** * The factory for expirable key value stores used by form cache. * * @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface @@ -188,8 +196,13 @@ protected function loadCachedFormState($form_build_id, FormStateInterface $form_ * {@inheritdoc} */ public function setCache($form_build_id, $form, FormStateInterface $form_state) { - // 6 hours cache life time for forms should be plenty. - $expire = 21600; + $system_form = $this->configFactory->get('system.form'); + if (empty($system_form)) { + $expire = static::CACHE_LIFETIME; + } + else { + $expire = $system_form->get('cache_lifetime'); + } // Ensure that the form build_id embedded in the form structure is the same // as the one passed in as a parameter. This is an additional safety measure diff --git a/core/modules/system/config/install/system.form.yml b/core/modules/system/config/install/system.form.yml new file mode 100644 index 0000000..9e2e584 --- /dev/null +++ b/core/modules/system/config/install/system.form.yml @@ -0,0 +1 @@ +cache_lifetime: 21600 diff --git a/core/modules/system/config/schema/system.schema.yml b/core/modules/system/config/schema/system.schema.yml index a8d13fa..f571a25 100644 --- a/core/modules/system/config/schema/system.schema.yml +++ b/core/modules/system/config/schema/system.schema.yml @@ -143,6 +143,14 @@ system.filter: - type: string label: 'Protocol' +system.form: + type: mapping + label: 'Form settings' + mapping: + cache_lifetime: + type: integer + label: 'Form cache lifetime' + system.logging: type: mapping label: 'Logging settings'