diff --git a/core/lib/Drupal/Core/Form/FormCache.php b/core/lib/Drupal/Core/Form/FormCache.php index 7064e10..9c931fd 100644 --- a/core/lib/Drupal/Core/Form/FormCache.php +++ b/core/lib/Drupal/Core/Form/FormCache.php @@ -8,6 +8,7 @@ use Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface; use Drupal\Core\PageCache\RequestPolicyInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Site\Settings; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -170,8 +171,8 @@ 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; + // Cache forms for 6 hours by default. + $expire = Settings::get('form_cache_expiration', 21600); // 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/sites/default/default.settings.php b/sites/default/default.settings.php index 25d498e..8111073 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -440,6 +440,20 @@ */ # $settings['cache_ttl_4xx'] = 3600; +/** + * Expiration of cache_form entries. + * + * Drupal's Form API stores details of forms in a cache and these entries are + * kept for at least 6 hours by default. Expired entries are cleared by cron. + * Busy sites can encounter problems with the cache_form table becoming very + * large. It's possible to mitigate this by setting a shorter expiration for + * cached forms. In some cases it may be desirable to set a longer cache + * expiration, for example to prolong cache_form entries for Ajax forms in + * cached HTML. + * + * @see \Drupal\Core\Form\FormCache::setCache() + */ +# $conf['form_cache_expiration'] = 21600; /** * Class Loader.