diff --git a/core/assets/scaffold/files/default.settings.php b/core/assets/scaffold/files/default.settings.php index 264597b163ba86ca16fb01641d312d55b4a30870..06d270abbbd04af07f541696875c4c11cab70119 100644 --- a/core/assets/scaffold/files/default.settings.php +++ b/core/assets/scaffold/files/default.settings.php @@ -807,16 +807,6 @@ */ $settings['entity_update_backup'] = TRUE; -/** - * State caching. - * - * State caching uses the cache collector pattern to cache all requested keys - * from the state API in a single cache entry, which can greatly reduce the - * amount of database queries. However, some sites may use state with a - * lot of dynamic keys which could result in a very large cache. - */ -$settings['state_cache'] = TRUE; - /** * Node migration type. * diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index 7516e64b7c73ad766d841236c27a9c0b0fa9bfcc..8bb39e8cf26131912668762b61b0fe4ed87fb878 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -46,6 +46,10 @@ final class Settings { 'replacement' => '', 'message' => 'The "yaml_parser_class" setting is deprecated in drupal:10.3.0. This setting should be removed from the settings file, since its usage has been removed. See https://www.drupal.org/node/3415489.', ], + 'state_cache' => [ + 'replacement' => '', + 'message' => 'The "state_cache" setting is deprecated in drupal:11.0.0. This setting should be removed from the settings file, since its usage has been removed. See https://www.drupal.org/node/3177901.', + ], ]; /** diff --git a/core/lib/Drupal/Core/State/State.php b/core/lib/Drupal/Core/State/State.php index 89c22ace4f778eed5ee371c5accde693b532c839..aa905e91cf31d63008c152ade7c9c74d4fee53f3 100644 --- a/core/lib/Drupal/Core/State/State.php +++ b/core/lib/Drupal/Core/State/State.php @@ -7,7 +7,6 @@ use Drupal\Core\Cache\CacheCollector; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\Lock\LockBackendInterface; -use Drupal\Core\Site\Settings; /** * Provides the state system using a key value store. @@ -47,23 +46,9 @@ class State extends CacheCollector implements StateInterface { * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. */ - public function __construct(KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache = NULL, LockBackendInterface $lock = NULL) { - if (!$cache) { - @trigger_error('Calling ' . __METHOD__ . '() without the $cache argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3177901', E_USER_DEPRECATED); - $cache = \Drupal::cache('bootstrap'); - } - if (!$lock) { - @trigger_error('Calling ' . __METHOD__ . '() without the $lock argument is deprecated in drupal:10.3.0 and is required in drupal:11.0.0. See https://www.drupal.org/node/3177901', E_USER_DEPRECATED); - $lock = \Drupal::service('lock'); - } + public function __construct(KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache, LockBackendInterface $lock) { parent::__construct('state', $cache, $lock); $this->keyValueStore = $key_value_factory->get('state'); - - // For backward compatibility, allow to opt-out of state caching, if cache - // is not explicitly enabled, flag the cache as already loaded. - if (Settings::get('state_cache') !== TRUE) { - $this->cacheLoaded = TRUE; - } } /** @@ -159,28 +144,4 @@ public function resetCache() { $this->clear(); } - /** - * {@inheritdoc} - */ - protected function updateCache($lock = TRUE) { - // For backward compatibility, allow to opt-out of state caching, if cache - // is not explicitly enabled, there is no need to update it. - if (Settings::get('state_cache') !== TRUE) { - return; - } - parent::updateCache($lock); - } - - /** - * {@inheritdoc} - */ - protected function invalidateCache() { - // For backward compatibility, allow to opt-out of state caching, if cache - // is not explicitly enabled, there is no need to invalidate it. - if (Settings::get('state_cache') !== TRUE) { - return; - } - parent::invalidateCache(); - } - } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index e679b9a619e2e914ac58d6d5e6e99aed8d60f80b..b8ef546639e742120a1599581843dc2afad0d20b 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1570,17 +1570,6 @@ function (callable $hook, string $module) use (&$module_list, $update_registry, } } - // Add warning if state caching is not explicitly set. - if ($phase === 'runtime') { - if (Settings::get('state_cache') === NULL) { - $requirements['state_cache_not_set'] = [ - 'title' => t('State cache flag not set'), - 'value' => t("State cache flag \$settings['state_cache'] is not set. It is recommended to be set to TRUE in settings.php unless there are too many state keys. Drupal 11 will default to having state cache enabled."), - 'severity' => REQUIREMENT_WARNING, - ]; - } - } - return $requirements; } diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index 264597b163ba86ca16fb01641d312d55b4a30870..06d270abbbd04af07f541696875c4c11cab70119 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -807,16 +807,6 @@ */ $settings['entity_update_backup'] = TRUE; -/** - * State caching. - * - * State caching uses the cache collector pattern to cache all requested keys - * from the state API in a single cache entry, which can greatly reduce the - * amount of database queries. However, some sites may use state with a - * lot of dynamic keys which could result in a very large cache. - */ -$settings['state_cache'] = TRUE; - /** * Node migration type. *