diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 7b638e5..39b82be 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -2,6 +2,7 @@ namespace Drupal\Core\Config\Entity; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigImporterException; @@ -104,9 +105,12 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. + * @param \Drupal\Core\Cache\CacheBackendInterface $static_cache_backend + * The static cache backend. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager) { - parent::__construct($entity_type); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, CacheBackendInterface $static_cache_backend = NULL) { + $static_cache_backend = isset($static_cache_backend) ? $static_cache_backemd : \Drupal::service('cache.static'); + parent::__construct($entity_type, $static_cache_backend); $this->configFactory = $config_factory; $this->uuidService = $uuid_service; diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 478bca7..84babd8 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -3,6 +3,7 @@ namespace Drupal\Core\Entity\KeyValueStore; use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; @@ -50,6 +51,13 @@ class KeyValueEntityStorage extends EntityStorageBase { protected $languageManager; /** + * The memory cache backend. + * + * @var \Drupal\Core\Cache\CacheBackendInterface + */ + protected $staticCacheBackend; + + /** * Constructs a new KeyValueEntityStorage. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -60,9 +68,11 @@ class KeyValueEntityStorage extends EntityStorageBase { * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. + * @param \Drupal\Core\Cache\CacheBackendInterface $static_cache_backend + * The static cache backend. */ - public function __construct(EntityTypeInterface $entity_type, KeyValueStoreInterface $key_value_store, UuidInterface $uuid_service, LanguageManagerInterface $language_manager) { - parent::__construct($entity_type); + public function __construct(EntityTypeInterface $entity_type, KeyValueStoreInterface $key_value_store, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, CacheBackendInterface $static_cache_backend) { + parent::__construct($entity_type, $static_cache_backend); $this->keyValueStore = $key_value_store; $this->uuidService = $uuid_service; $this->languageManager = $language_manager; diff --git a/core/modules/migrate/src/MigrationStorage.php b/core/modules/migrate/src/MigrationStorage.php index 282b0c9..ae3ae88 100644 --- a/core/modules/migrate/src/MigrationStorage.php +++ b/core/modules/migrate/src/MigrationStorage.php @@ -4,6 +4,7 @@ use Drupal\Component\Graph\Graph; use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Entity\EntityTypeInterface; @@ -36,9 +37,12 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend * The language manager. * @param \Drupal\Core\Entity\Query\QueryFactoryInterface $query_factory * The entity query factory service. + * @param \Drupal\Core\Cache\CacheBackendInterface + * The static cache backend. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, QueryFactoryInterface $query_factory) { - parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, QueryFactoryInterface $query_factory, CacheBackendInterface $static_cache_backend = NULL) { + $static_cache_backend = isset($static_cache_backend) ? $static_cache_backend : \Drupal::service('cache.static'); + parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $static_cache_backend); $this->queryFactory = $query_factory; } diff --git a/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php b/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php index 3ff44fa..8ce528f 100644 --- a/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrationStorageTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\migrate\Unit; use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Query\QueryFactoryInterface; @@ -53,7 +54,8 @@ protected function setUp() { $this->getMock(ConfigFactoryInterface::class), $this->getMock(UuidInterface::class), $this->getMock(LanguageManagerInterface::class), - $query_factory + $query_factory, + new MemoryBackend('static') ); } diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php index 3c337bb..5a07d7f 100644 --- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\Core\Entity\KeyValueStore { +use Drupal\Core\Cache\MemoryBackend; use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityInterface; @@ -120,7 +121,7 @@ protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') { ->method('getCurrentLanguage') ->will($this->returnValue($language)); - $this->entityStorage = new KeyValueEntityStorage($this->entityType, $this->keyValueStore, $this->uuidService, $this->languageManager); + $this->entityStorage = new KeyValueEntityStorage($this->entityType, $this->keyValueStore, $this->uuidService, $this->languageManager, new MemoryBackend('static')); $this->entityStorage->setModuleHandler($this->moduleHandler); $container = new ContainerBuilder();