diff --git a/core/core.services.yml b/core/core.services.yml index 465d145..aacd7bf 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -125,10 +125,10 @@ services: factory_class: Drupal\Component\Utility\Settings factory_method: getSingleton state: - class: Drupal\Core\KeyValueStore\KeyValueStoreInterface - factory_method: get - factory_service: keyvalue - arguments: [state] + class: Drupal\Core\KeyValueStore\State + arguments: ['@keyvalue'] + tags: + - { name: persist } queue: class: Drupal\Core\Queue\QueueFactory arguments: ['@settings'] diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 0d100df..6cdadd8 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -288,7 +288,7 @@ public static function keyValue($collection) { * needs to be the same across development, production, etc. environments * (for example, the system maintenance message) should use \Drupal::config() instead. * - * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @return \Drupal\Core\KeyValueStore\StateInterface */ public static function state() { return static::$container->get('state'); diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php index 5d43231..5bc4a7d 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php @@ -8,6 +8,7 @@ use Drupal\Core\Asset\AssetCollectionOptimizerInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Optimizes CSS assets. @@ -38,7 +39,7 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -51,10 +52,10 @@ class CssCollectionOptimizer implements AssetCollectionOptimizerInterface { * The optimizer for a single CSS asset. * @param \Drupal\Core\Asset\AssetDumperInterface * The dumper for optimized CSS assets. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @param \Drupal\Core\KeyValueStore\StateInterface * The state key/value store. */ - public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, KeyValueStoreInterface $state) { + public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) { $this->grouper = $grouper; $this->optimizer = $optimizer; $this->dumper = $dumper; diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php index bf4cbf6..0efe554 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Asset; use Drupal\Core\Asset\AssetCollectionOptimizerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** @@ -39,7 +39,7 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface { /** * The state key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -55,7 +55,7 @@ class JsCollectionOptimizer implements AssetCollectionOptimizerInterface { * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface * The state key/value store. */ - public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, KeyValueStoreInterface $state) { + public function __construct(AssetCollectionGrouperInterface $grouper, AssetOptimizerInterface $optimizer, AssetDumperInterface $dumper, StateInterface $state) { $this->grouper = $grouper; $this->optimizer = $optimizer; $this->dumper = $dumper; diff --git a/core/lib/Drupal/Core/Extension/CachedModuleHandler.php b/core/lib/Drupal/Core/Extension/CachedModuleHandler.php index 6e09432..0def7f3 100644 --- a/core/lib/Drupal/Core/Extension/CachedModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/CachedModuleHandler.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Extension; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Class that manages enabled modules in a Drupal installation. @@ -18,7 +18,7 @@ class CachedModuleHandler extends ModuleHandler implements CachedModuleHandlerIn /** * State key/value store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -39,7 +39,7 @@ class CachedModuleHandler extends ModuleHandler implements CachedModuleHandlerIn /** * Constructs a new CachedModuleHandler object. */ - public function __construct(array $module_list = array(), KeyValueStoreInterface $state, CacheBackendInterface $bootstrap_cache) { + public function __construct(array $module_list = array(), StateInterface $state, CacheBackendInterface $bootstrap_cache) { parent::__construct($module_list); $this->state = $state; $this->bootstrapCache = $bootstrap_cache; diff --git a/core/lib/Drupal/Core/KeyValueStore/State.php b/core/lib/Drupal/Core/KeyValueStore/State.php new file mode 100644 index 0000000..57b96dc --- /dev/null +++ b/core/lib/Drupal/Core/KeyValueStore/State.php @@ -0,0 +1,123 @@ +keyValueStore = $keyValueFactory->get('state'); + } + + /** + * {@inheritdoc} + */ + public function getMultiple(array $keys) { + $values = array(); + $load = array(); + foreach ($keys as $key) { + // Check if we have a value in the cache. + if (isset($this->cache[$key])) { + $values[$key] = $this->cache[$key]; + } + // Load the value if we don't have an explicit NULL value. + elseif (!array_key_exists($key, $this->cache)) { + $load[] = $key; + } + } + + if ($load) { + $loaded_values = $this->keyValueStore->getMultiple($load); + foreach ($load as $key) { + if (isset($loaded_values[$key]) || array_key_exists($key, $loaded_values)) { + $values[$key] = $loaded_values[$key]; + $this->cache[$key] = $loaded_values[$key]; + } + else { + $this->cache[$key] = NULL; + } + } + } + + return $values; + } + + /** + * {@inheritdoc} + */ + public function set($key, $value) { + $this->cache[$key] = $value; + $this->keyValueStore->set($key, $value); + } + + /** + * {@inheritdoc} + */ + public function deleteMultiple(array $keys) { + foreach ($keys as $key) { + unset($this->cache[$key]); + } + $this->keyValueStore->deleteMultiple($keys); + } + + + /** + * {@inheritdoc} + */ + public function get($key) { + $values = $this->getMultiple(array($key)); + return isset($values[$key]) ? $values[$key] : NULL; + } + + /** + * {@inheritdoc} + */ + public function setMultiple(array $data) { + foreach ($data as $key => $value) { + $this->cache[$key] = $value; + } + $this->setMultiple($data); + } + + /** + * {@inheritdoc} + */ + public function delete($key) { + $this->deleteMultiple(array($key)); + } + + /** + * {@inheritdoc} + */ + public function resetCache() { + $this->cache = array(); + } + +} diff --git a/core/lib/Drupal/Core/KeyValueStore/StateInterface.php b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php new file mode 100644 index 0000000..9e248d8 --- /dev/null +++ b/core/lib/Drupal/Core/KeyValueStore/StateInterface.php @@ -0,0 +1,78 @@ +state = $state; } diff --git a/core/lib/Drupal/Core/Path/AliasWhitelist.php b/core/lib/Drupal/Core/Path/AliasWhitelist.php index 9e3a6a1..12e6883 100644 --- a/core/lib/Drupal/Core/Path/AliasWhitelist.php +++ b/core/lib/Drupal/Core/Path/AliasWhitelist.php @@ -12,6 +12,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\DestructableInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Utility\CacheArray; @@ -23,7 +24,7 @@ class AliasWhitelist extends CacheCollector { /** * The Key/Value Store to use for state. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -43,12 +44,12 @@ class AliasWhitelist extends CacheCollector { * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state keyvalue store. * @param \Drupal\Core\Database\Connection $connection * The database connection. */ - public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, KeyValueStoreInterface $state, Connection $connection) { + public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, StateInterface $state, Connection $connection) { parent::__construct($cid, $cache, $lock); $this->state = $state; $this->connection = $connection; diff --git a/core/lib/Drupal/Core/PrivateKey.php b/core/lib/Drupal/Core/PrivateKey.php index fd8bb55..762a664 100644 --- a/core/lib/Drupal/Core/PrivateKey.php +++ b/core/lib/Drupal/Core/PrivateKey.php @@ -7,7 +7,7 @@ namespace Drupal\Core; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Component\Utility\Crypt; /** @@ -18,17 +18,17 @@ class PrivateKey { /** * The state service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructs the token generator. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state service. */ - function __construct(KeyValueStoreInterface $state) { + function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php index 915e4bb..fefb9fd 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php @@ -75,6 +75,7 @@ public function testLanguageBlockVisibility() { // Reset the static cache of the language list. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); // Check that a page has a block. $this->drupalget('', array('language' => language_load('en'))); diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php index 2b4ef46..f85771e 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php @@ -16,7 +16,7 @@ use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Extension\ModuleHandler; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Controller class for field instances. @@ -45,7 +45,7 @@ class FieldInstanceStorageController extends ConfigStorageController { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -68,10 +68,10 @@ class FieldInstanceStorageController extends ConfigStorageController { * The entity manager. * @param \Drupal\Core\Extension\ModuleHandler $module_handler * The module handler. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManager $entity_manager, ModuleHandler $module_handler, KeyValueStoreInterface $state) { + public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManager $entity_manager, ModuleHandler $module_handler, StateInterface $state) { parent::__construct($entity_type, $entity_info, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/field/lib/Drupal/field/FieldStorageController.php b/core/modules/field/lib/Drupal/field/FieldStorageController.php index fff0df7..4fb0c1c 100644 --- a/core/modules/field/lib/Drupal/field/FieldStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldStorageController.php @@ -16,7 +16,7 @@ use Drupal\Core\Config\StorageInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Extension\ModuleHandler; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; /** * Controller class for fields. @@ -40,7 +40,7 @@ class FieldStorageController extends ConfigStorageController { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -63,10 +63,10 @@ class FieldStorageController extends ConfigStorageController { * The entity manager. * @param \Drupal\Core\Extension\ModuleHandler $module_handler * The module handler. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManager $entity_manager, ModuleHandler $module_handler, KeyValueStoreInterface $state) { + public function __construct($entity_type, array $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManager $entity_manager, ModuleHandler $module_handler, StateInterface $state) { parent::__construct($entity_type, $entity_info, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index 96305bd..b6fb820 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -38,6 +38,8 @@ function setUp() { * 'insert', etc. */ function assertFileHooksCalled($expected) { + \Drupal::state()->resetCache(); + // Determine which hooks were called. $actual = array_keys(array_filter(file_test_get_all_calls())); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php index 1fb8c85..3381d44 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php @@ -72,6 +72,8 @@ function testLanguageConfiguration() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertOptionSelected('edit-site-default-language', 'fr', 'Default language updated.'); + + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url('admin/config/regional/settings', array('absolute' => TRUE)), 'Correct page redirection.'); // Check if a valid language prefix is added after changing the default diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 8b2190d..b05808d 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -72,6 +72,7 @@ function testLanguageList() { ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertNoOptionSelected('edit-site-default-language', 'en', 'Default language updated.'); + \Drupal::state()->resetCache(); $this->assertEqual($this->getUrl(), url($path, array('absolute' => TRUE)), 'Correct page redirection.'); // Ensure we can't delete the default language. @@ -96,6 +97,7 @@ function testLanguageList() { 'site_default_language' => 'en', ); $this->drupalPostForm($path, $edit, t('Save configuration')); + \Drupal::state()->resetCache(); // Ensure 'delete' link works. $this->drupalGet('admin/config/regional/language'); $this->clickLink(t('Delete')); @@ -125,6 +127,7 @@ function testLanguageList() { $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); // Get the count of languages. drupal_static_reset('language_list'); + \Drupal::state()->resetCache(); $languages = language_list(); // We need raw here because %language and %langcode will add HTML. $t_args = array('%language' => 'French', '%langcode' => 'fr'); diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index c33da33..ea4c9ce 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -11,7 +11,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\locale\StringStorageInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -31,7 +31,7 @@ /** * The state store. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -54,12 +54,12 @@ * * @param \Drupal\locale\StringStorageInterface $locale_storage * The locale storage. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state service. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(StringStorageInterface $locale_storage, KeyValueStoreInterface $state, LanguageManager $language_manager) { + public function __construct(StringStorageInterface $locale_storage, StateInterface $state, LanguageManager $language_manager) { $this->localeStorage = $locale_storage; $this->state = $state; $this->languageManager = $language_manager; diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index 8cd217b..dff7ec3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -136,6 +136,7 @@ function testStandalonePoFile() { $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $this->assertNoText(t('No strings available.'), 'String overwritten by imported string.'); // This import should have changed number of plural forms. + \Drupal::state()->resetCache(); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $this->assert($locale_plurals['fr']['plurals'] == 3, 'Plural numbers changed.'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php index 3d20f6d..1ed7800 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -130,6 +130,7 @@ function testUpdateCheckStatus() { // Get status of translation sources at both local and remote locations. $this->drupalGet('admin/reports/translations/check'); + \Drupal::state()->resetCache(); $result = locale_translation_get_status(); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_REMOTE, 'Translation of contrib_module_one found'); $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index cdc399f..57fd328 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -14,7 +14,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Session\AccountInterface; @@ -68,7 +68,7 @@ class NodeSearch extends SearchPluginBase implements AccessibleInterface, Search /** * The Drupal state object used to set 'node.cron_last'. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -111,7 +111,7 @@ static public function create(ContainerInterface $container, array $configuratio $container->get('plugin.manager.entity'), $container->get('module_handler'), $container->get('config.factory')->get('search.settings'), - $container->get('keyvalue')->get('state'), + $container->get('state'), $container->get('current_user') ); } @@ -133,12 +133,12 @@ static public function create(ContainerInterface $container, array $configuratio * A module manager object. * @param \Drupal\Core\Config\Config $search_settings * A config object for 'search.settings'. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The Drupal state object used to set 'node.cron_last'. * @param \Drupal\Core\Session\AccountInterface $account * The $account object to use for checking for access to advanced search. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, KeyValueStoreInterface $state, AccountInterface $account = NULL) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $database, EntityManager $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, StateInterface $state, AccountInterface $account = NULL) { $this->database = $database; $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php index 66ea769..f07f3e1 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php @@ -55,6 +55,7 @@ function testNodeTypeCustomizationPersistence() { $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); $this->drupalPostForm(NULL, array(), t('Uninstall')); $forum = entity_load('node_type', 'forum'); + \Drupal::state()->resetCache(); $this->assertFalse($forum->isLocked(), 'Forum node type is not locked'); $this->drupalGet('node/add'); $this->assertNoText('forum', 'forum type is no longer found on node/add'); diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index 3f21186..19383a9 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Plugin\PluginFormInterface; use Drupal\search\SearchPluginManager; use Drupal\Core\Form\ConfigFormBase; @@ -44,7 +44,7 @@ class SearchSettingsForm extends ConfigFormBase { /** * The Drupal state storage service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -59,10 +59,10 @@ class SearchSettingsForm extends ConfigFormBase { * The manager for search plugins. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key/value store interface, gives access to state based config settings. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, SearchPluginManager $manager, ModuleHandlerInterface $module_handler, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, SearchPluginManager $manager, ModuleHandlerInterface $module_handler, StateInterface $state) { parent::__construct($config_factory, $context); $this->searchSettings = $config_factory->get('search.settings'); $this->searchPluginManager = $manager; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index a307e32..71bc8e5 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -2434,6 +2434,7 @@ protected function drupalGetSettings() { * An array containing e-mail messages captured during the current test. */ protected function drupalGetMails($filter = array()) { + \Drupal::state()->resetCache(); $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array(); $filtered_emails = array(); diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php index 12802e4..8ddc297 100644 --- a/core/modules/system/lib/Drupal/system/Form/CronForm.php +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -22,7 +22,7 @@ class CronForm extends ConfigFormBase { /** * Stores the state storage service. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -33,10 +33,10 @@ class CronForm extends ConfigFormBase { * The factory for configuration objects. * @param \Drupal\Core\Config\Context\ContextInterface $context * The configuration context used for this configuration object. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, StateInterface $state) { parent::__construct($config_factory, $context); $this->state = $state; } diff --git a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php index 131af5b..86e012d 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php @@ -9,7 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Form\ConfigFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,7 +21,7 @@ class SiteMaintenanceModeForm extends ConfigFormBase { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; @@ -32,10 +32,10 @@ class SiteMaintenanceModeForm extends ConfigFormBase { * The factory for configuration objects. * @param \Drupal\Core\Config\Context\ContextInterface $context * The configuration context to use. - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state keyvalue collection to use. */ - public function __construct(ConfigFactory $config_factory, ContextInterface $context, KeyValueStoreInterface $state) { + public function __construct(ConfigFactory $config_factory, ContextInterface $context, StateInterface $state) { parent::__construct($config_factory, $context); $this->state = $state; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php index de63b73..83c8671 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php @@ -54,6 +54,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_1'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -61,6 +62,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_2'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -68,6 +70,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_3'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_3'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); @@ -75,6 +78,7 @@ function testBatchForm() { $edit = array('batch' => 'batch_4'); $this->drupalPostForm('batch-test', $edit, 'Submit'); $this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.'); + \Drupal::state()->resetCache(); $this->assertEqual(batch_test_stack(), $this->_resultStack('batch_4'), 'Execution order was correct.'); $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 78326e9..18dc465 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -113,6 +113,7 @@ function testEntityFormLanguage() { $node->getTranslation($langcode2)->body->value = $this->randomName(16); $node->save(); $this->drupalGet($langcode2 . '/node/' . $node->id() . '/edit'); + \Drupal::state()->resetCache(); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; $this->assertTrue($langcode2 == $form_langcode, "Node edit form language is $langcode2."); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php index 409f3aa..ee61284 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php @@ -93,6 +93,7 @@ function testCustom403And404Pages() { // Check that the initial trail (during the Drupal bootstrap) matches // what we expect. + \Drupal::state()->resetCache(); $initial_trail = \Drupal::state()->get('menu_test.active_trail_initial') ?: array(); $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array( '@status_code' => $status_code, diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index 6fe28f2..996dea4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -68,6 +68,7 @@ function testAutomaticCron() { \Drupal::state()->set('system.cron_last', $cron_last); $this->drupalGet(''); sleep(1); + \Drupal::state()->resetCache(); $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); // Disable the cron threshold through the interface. diff --git a/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php b/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php index 1c8ea06..9078493 100644 --- a/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php +++ b/core/modules/system/tests/modules/service_provider_test/lib/Drupal/service_provider_test/TestClass.php @@ -7,7 +7,7 @@ namespace Drupal\service_provider_test; -use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\DestructableInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseEvent; @@ -18,17 +18,17 @@ class TestClass implements EventSubscriberInterface, DestructableInterface { /** * The state keyvalue collection. * - * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * @var \Drupal\Core\KeyValueStore\StateInterface */ protected $state; /** * Constructor. * - * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state + * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(KeyValueStoreInterface $state) { + public function __construct(StateInterface $state) { $this->state = $state; } diff --git a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php index a77a939..8e62f1c 100644 --- a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php +++ b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php @@ -52,7 +52,7 @@ public function setUp() { parent::setUp(); $this->key = Crypt::randomStringHashed(55); - $this->state = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface'); + $this->state = $this->getMock('Drupal\Core\KeyValueStore\StateInterface'); $this->privateKey = new PrivateKey($this->state); }