diff --git a/core/core.services.yml b/core/core.services.yml index 66ab7333cced6a39d43c64a3fd35113b4e3f3f23..808f492c5f0a588d98bfd7ed4af9754674fa8bd4 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1419,7 +1419,7 @@ services: Drupal\Core\Executable\ExecutableManagerInterface: '@plugin.manager.condition' plugin.manager.element_info: class: Drupal\Core\Render\ElementInfoManager - arguments: ['@container.namespaces', '@cache.discovery', '@cache_tags.invalidator', '@module_handler', '@theme.manager'] + arguments: ['@container.namespaces', '@cache.discovery', '@theme_handler', '@module_handler', '@theme.manager'] Drupal\Core\Render\ElementInfoManagerInterface: '@plugin.manager.element_info' stream_wrapper_manager: class: Drupal\Core\StreamWrapper\StreamWrapperManager diff --git a/core/lib/Drupal/Core/Http/LinkRelationTypeManager.php b/core/lib/Drupal/Core/Http/LinkRelationTypeManager.php index 11887aa18f7d46d5e78f32867a5b59008b40421d..d30c299a42a02fb19ced5d8a1dc2048b9d59599e 100644 --- a/core/lib/Drupal/Core/Http/LinkRelationTypeManager.php +++ b/core/lib/Drupal/Core/Http/LinkRelationTypeManager.php @@ -43,7 +43,7 @@ public function __construct($root, ModuleHandlerInterface $module_handler, Cache $this->root = $root; $this->pluginInterface = LinkRelationTypeInterface::class; $this->moduleHandler = $module_handler; - $this->setCacheBackend($cache, 'link_relation_type_plugins', ['link_relation_type']); + $this->setCacheBackend($cache, 'link_relation_type_plugins'); } /** diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php index 5b8b609b8180d5fe82ec2587ad76031c9fb9cb8a..e67bd0e0840f4bf9d483dd67f95fbd84b6d0150a 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -72,6 +72,13 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi */ protected $requestStack; + /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected LanguageManagerInterface $languageManager; + /** * A static cache of all the contextual link plugins by group name. * @@ -104,8 +111,9 @@ public function __construct(ControllerResolverInterface $controller_resolver, Mo $this->account = $account; $this->moduleHandler = $module_handler; $this->requestStack = $request_stack; + $this->languageManager = $language_manager; $this->alterInfo('contextual_links_plugins'); - $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['contextual_links_plugins']); + $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId()); } /** @@ -191,4 +199,16 @@ public function getContextualLinksArrayByGroup($group_name, array $route_paramet return $links; } + /** + * {@inheritdoc} + */ + public function clearCachedDefinitions() { + $cids = []; + foreach ($this->languageManager->getLanguages() as $language) { + $cids[] = 'contextual_links_plugins:' . $language->getId(); + } + $this->cacheBackend->deleteMultiple($cids); + $this->definitions = NULL; + } + } diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index 65b5c94afc04a2fce42fa9dc61a9cb03b29033b3..cfd3b55d96463a73e0c63a9d27b4182a00ab0802 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -89,6 +89,13 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana */ protected $account; + /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected LanguageManagerInterface $languageManager; + /** * The plugin instances. * @@ -129,8 +136,9 @@ public function __construct(ArgumentResolverInterface $argument_resolver, Reques $this->accessManager = $access_manager; $this->moduleHandler = $module_handler; $this->account = $account; + $this->languageManager = $language_manager; $this->alterInfo('menu_local_actions'); - $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['local_action']); + $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId()); } /** @@ -200,4 +208,16 @@ public function getActionsForRoute($route_appears) { return $links; } + /** + * {@inheritdoc} + */ + public function clearCachedDefinitions() { + $cids = []; + foreach ($this->languageManager->getLanguages() as $language) { + $cids[] = 'local_action_plugins:' . $language->getId(); + } + $this->cacheBackend->deleteMultiple($cids); + $this->definitions = NULL; + } + } diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php index 37f485793b58e4d26f226182a2a7ded4490ab9af..126eb50d8d2dc8e605d62d0bc35f7c948e67091d 100644 --- a/core/lib/Drupal/Core/Render/ElementInfoManager.php +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php @@ -2,10 +2,11 @@ namespace Drupal\Core\Render; -use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Render\Element\FormElementInterface; use Drupal\Core\Theme\ThemeManagerInterface; @@ -23,6 +24,15 @@ */ class ElementInfoManager extends DefaultPluginManager implements ElementInfoManagerInterface { + use DeprecatedServicePropertyTrait; + + /** + * Defines deprecated injected properties. + * + * @var array + */ + protected array $deprecatedProperties = ['cacheTagInvalidator' => 'cache_tags.invalidator']; + /** * Stores the available element information. * @@ -38,11 +48,11 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana protected $themeManager; /** - * The cache tag invalidator. + * The theme handler. * * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface */ - protected $cacheTagInvalidator; + protected $themeHandler; /** * Constructs an ElementInfoManager object. @@ -52,17 +62,21 @@ class ElementInfoManager extends DefaultPluginManager implements ElementInfoMana * keyed by the corresponding namespace to look for plugin implementations. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend instance to use. - * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tag_invalidator - * The cache tag invalidator. + * @param \Drupal\Core\Extension\ThemeHandlerInterface|\Drupal\Core\Cache\CacheTagsInvalidatorInterface $theme_handler + * The theme handler. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke the alter hook with. * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager * The theme manager. */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, CacheTagsInvalidatorInterface $cache_tag_invalidator, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) { + public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ThemeHandlerInterface|CacheTagsInvalidatorInterface $theme_handler, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) { $this->setCacheBackend($cache_backend, 'element_info'); $this->themeManager = $theme_manager; - $this->cacheTagInvalidator = $cache_tag_invalidator; + if ($theme_handler instanceof CacheTagsInvalidatorInterface) { + @trigger_error('Calling ' . __METHOD__ . '() with the $cache_tag_invalidator argument is deprecated and replaced with $theme_handler in drupal:10.2.0 and will be removed in drupal:11.0.0.', E_USER_DEPRECATED); + $theme_handler = \Drupal::service('theme_handler'); + } + $this->themeHandler = $theme_handler; parent::__construct('Element', $namespaces, $module_handler, 'Drupal\Core\Render\Element\ElementInterface', 'Drupal\Core\Render\Annotation\RenderElement'); $this->alterInfo('element_plugin'); @@ -138,7 +152,7 @@ protected function buildInfo($theme_name) { $this->moduleHandler->alter('element_info', $info); $this->themeManager->alter('element_info', $info); - $this->cacheBackend->set($cid, $info, Cache::PERMANENT, ['element_info_build']); + $this->cacheBackend->set($cid, $info); return $info; } @@ -157,7 +171,13 @@ public function createInstance($plugin_id, array $configuration = []) { */ public function clearCachedDefinitions() { $this->elementInfo = NULL; - $this->cacheTagInvalidator->invalidateTags(['element_info_build']); + + $cids = []; + foreach ($this->themeHandler->listInfo() as $theme_name => $info) { + $cids[] = $this->getCid($theme_name); + } + + $this->cacheBackend->deleteMultiple($cids); parent::clearCachedDefinitions(); } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 86f39ffcf0201ae3118f14627a6cf57ca38f1941..f0e6118a398cf63a2d7c3a0e0a886fc5f5e4414d 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -264,7 +264,7 @@ public function get() { public function getRuntime() { $this->init($this->themeName); if (!isset($this->runtimeRegistry[$this->theme->getName()])) { - $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, ['theme_registry'], $this->moduleHandler->isLoaded()); + $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, [], $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry[$this->theme->getName()]; } @@ -273,7 +273,7 @@ public function getRuntime() { * Persists the theme registry in the cache backend. */ protected function setCache() { - $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()], Cache::PERMANENT, ['theme_registry']); + $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()]); } /** @@ -349,7 +349,7 @@ protected function build() { }); // Only cache this registry if all modules are loaded. if ($this->moduleHandler->isLoaded()) { - $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, ['theme_registry']); + $this->cache->set("theme_registry:build:modules", $cache); } } @@ -768,7 +768,18 @@ public function reset() { // rendered output varies by theme, however the tabs on the appearance page // depend on the theme list, so invalidate those via the local tasks cache // tag. - Cache::invalidateTags(['theme_registry', 'local_task']); + Cache::invalidateTags(['local_task']); + + $cids = ['theme_registry:build:modules']; + foreach ($this->themeHandler->listInfo() as $theme_name => $info) { + $cids[] = 'theme_registry:' . $theme_name; + $cids[] = 'theme_registry:runtime:' . $theme_name; + } + $this->cache->deleteMultiple($cids); + if ($this->runtimeCache) { + $this->runtimeCache->deleteMultiple($cids); + } + return $this; } diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php index a43f08083a5422d12e0cef550f917e88e557f0ae..13f57db0c24463bcac68fec653ff71a6335b5fff 100644 --- a/core/modules/config_translation/src/ConfigMapperManager.php +++ b/core/modules/config_translation/src/ConfigMapperManager.php @@ -36,6 +36,13 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa */ protected $themeHandler; + /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected LanguageManagerInterface $languageManager; + /** * {@inheritdoc} */ @@ -62,6 +69,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa */ public function __construct(CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, TypedConfigManagerInterface $typed_config_manager, ThemeHandlerInterface $theme_handler) { $this->typedConfigManager = $typed_config_manager; + $this->languageManager = $language_manager; $this->factory = new ContainerFactory($this, '\Drupal\config_translation\ConfigMapperInterface'); @@ -72,7 +80,7 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $this->alterInfo('config_translation_info'); // Config translation only uses an info hook discovery, cache by language. $cache_key = 'config_translation_info_plugins' . ':' . $language_manager->getCurrentLanguage()->getId(); - $this->setCacheBackend($cache_backend, $cache_key, ['config_translation_info_plugins']); + $this->setCacheBackend($cache_backend, $cache_key); } /** @@ -196,4 +204,16 @@ protected function findTranslatable(TypedDataInterface $element) { } } + /** + * {@inheritdoc} + */ + public function clearCachedDefinitions() { + $cids = []; + foreach ($this->languageManager->getLanguages() as $language) { + $cids[] = 'config_translation_info_plugins:' . $language->getId(); + } + $this->cacheBackend->deleteMultiple($cids); + $this->definitions = NULL; + } + } diff --git a/core/modules/help/help.module b/core/modules/help/help.module index e550e27fcca7303503634eafbe4683477a1ad22c..5d5e24a6b1823284307150512bb918ac4bb770b8 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -113,6 +113,7 @@ function help_modules_uninstalled(array $modules) { * Implements hook_themes_uninstalled(). */ function help_themes_uninstalled(array $themes) { + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); _help_search_update(); } @@ -127,6 +128,7 @@ function help_modules_installed(array $modules, $is_syncing) { * Implements hook_themes_installed(). */ function help_themes_installed(array $themes) { + \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); _help_search_update(); } diff --git a/core/modules/help/src/HelpTopicPluginManager.php b/core/modules/help/src/HelpTopicPluginManager.php index 5c95d8ed3fb74cd3a4cfb6b90493b95c1ad2dbad..fb0a5676cf20d37ccca6cd34ae1c9985e16d7093 100644 --- a/core/modules/help/src/HelpTopicPluginManager.php +++ b/core/modules/help/src/HelpTopicPluginManager.php @@ -100,9 +100,7 @@ public function __construct(ModuleHandlerInterface $module_handler, protected Th // annotated class discovery. $this->moduleHandler = $module_handler; $this->alterInfo('help_topics_info'); - // Use the 'config:core.extension' cache tag so the plugin cache is - // invalidated on theme install and uninstall. - $this->setCacheBackend($cache_backend, 'help_topics', ['config:core.extension']); + $this->setCacheBackend($cache_backend, 'help_topics'); } /** diff --git a/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php index df1915372242c9ee0807cfa1a7e1d15c8f94d336..577879909d8698ef6f4b5e83df34aabc678dee69 100644 --- a/core/modules/migrate/src/Plugin/MigrationPluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php @@ -55,7 +55,7 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager) { $this->factory = new ContainerFactory($this, $this->pluginInterface); $this->alterInfo('migration_plugins'); - $this->setCacheBackend($cache_backend, 'migration_plugins', ['migration_plugins']); + $this->setCacheBackend($cache_backend, 'migration_plugins'); $this->moduleHandler = $module_handler; } diff --git a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php index 8202edd2e7782366e3f875daa69668367b7972e8..5a0f6aa740b1c014b4e0ccdc77d917cf04ba6a90 100644 --- a/core/modules/system/src/EventSubscriber/ConfigCacheTag.php +++ b/core/modules/system/src/EventSubscriber/ConfigCacheTag.php @@ -6,6 +6,7 @@ use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; use Drupal\Core\Extension\ThemeHandlerInterface; +use Drupal\Core\Theme\Registry; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -34,10 +35,16 @@ class ConfigCacheTag implements EventSubscriberInterface { * The theme handler. * @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator * The cache tags invalidator. + * @param \Drupal\Core\Theme\Registry|null $themeRegistry + * The theme registry. */ - public function __construct(ThemeHandlerInterface $theme_handler, CacheTagsInvalidatorInterface $cache_tags_invalidator) { + public function __construct(ThemeHandlerInterface $theme_handler, CacheTagsInvalidatorInterface $cache_tags_invalidator, protected ?Registry $themeRegistry = NULL) { $this->themeHandler = $theme_handler; $this->cacheTagsInvalidator = $cache_tags_invalidator; + if ($this->themeRegistry === NULL) { + @trigger_error('Calling ' . __METHOD__ . '() without the $themeRegistry argument is deprecated in drupal:10.2.0 and will be required in drupal:11.0.0.', E_USER_DEPRECATED); + $this->themeRegistry = \Drupal::service('theme.registry'); + } } /** @@ -63,7 +70,8 @@ public function onSave(ConfigCrudEvent $event) { // Library and template overrides potentially change for the default theme // when the admin theme is changed. if ($config_name === 'system.theme' && $event->isChanged('admin')) { - $this->cacheTagsInvalidator->invalidateTags(['library_info', 'theme_registry']); + $this->themeRegistry->reset(); + $this->cacheTagsInvalidator->invalidateTags(['library_info']); } // Theme-specific settings, check if this matches a theme settings diff --git a/core/modules/system/system.services.yml b/core/modules/system/system.services.yml index 36e821d8c87839e200b11edb2b0fbfe7abde344e..8399f7fbafd1f07894e0a6752417c4e8b00d8949 100644 --- a/core/modules/system/system.services.yml +++ b/core/modules/system/system.services.yml @@ -41,7 +41,7 @@ services: - { name: event_subscriber } system.config_cache_tag: class: Drupal\system\EventSubscriber\ConfigCacheTag - arguments: ['@theme_handler', '@cache_tags.invalidator'] + arguments: ['@theme_handler', '@cache_tags.invalidator', '@theme.registry'] tags: - { name: event_subscriber } system.timezone_resolver: diff --git a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php index 4abbfdb63a57fcabe29af0f2510eb6e1280ac8b6..03c3089270d05dc19404f22d8e0c2e138a00955e 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php @@ -92,7 +92,7 @@ public function testTwigCacheOverride() { $this->container->set('theme.registry', NULL); // Load array of Twig templates. - // reset() is necessary to invalidate caches tagged with 'theme_registry'. + // reset() is necessary to invalidate caches. $registry = $this->container->get('theme.registry'); $registry->reset(); $templates = $registry->getRuntime(); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/BrokenCacheUpdateTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/BrokenCacheUpdateTest.php index 23c864d44aa992e80e37fe83eedef8e6bf9097e9..a7bf1ac20d341414a8b422336906867de2fd4e09 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/BrokenCacheUpdateTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/BrokenCacheUpdateTest.php @@ -47,7 +47,6 @@ public function testUpdate() { ]; $insert->fields($fields); $fields['cid'] = 'element_info_build:claro'; - $fields['tags'] = 'element_info_build'; $insert->values(array_values($fields)); $fields['cid'] = 'element_info_build:stark'; $insert->values(array_values($fields)); diff --git a/core/phpstan.neon.dist b/core/phpstan.neon.dist index ded80395186c1f7ab74283a4cfc01f6b2c14b6e6..cf022ac13f9367ce53ad5a9171a0eac5d9ef1363 100644 --- a/core/phpstan.neon.dist +++ b/core/phpstan.neon.dist @@ -35,5 +35,4 @@ parameters: - "#Drupal calls should be avoided in classes, use dependency injection instead#" - "#^Plugin definitions cannot be altered.#" - "#^Missing cache backend declaration for performance.#" - - "#cache tag might be unclear and does not contain the cache key in it.#" - "#^Class .* extends @internal class#" diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php index c4669370b2b7e49a2f524e59b363e723980b3dbd..0649a22c885824fd095239bb99450f67dc2485ae 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php @@ -39,7 +39,7 @@ public function testRaceCondition() { // entry to be written in __construct(). $cache = \Drupal::cache(); $lock_backend = \Drupal::lock(); - $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded()); + $registry = new ThemeRegistry($cid, $cache, $lock_backend, [], $this->container->get('module_handler')->isLoaded()); $this->assertNotEmpty(\Drupal::cache()->get($cid), 'Cache entry was created.'); @@ -59,7 +59,7 @@ public function testRaceCondition() { // Create a new instance of the class. Confirm that both the offset // requested previously, and one that has not yet been requested are both // available. - $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded()); + $registry = new ThemeRegistry($cid, $cache, $lock_backend, [], $this->container->get('module_handler')->isLoaded()); $this->assertNotEmpty($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry'); $this->assertNotEmpty($registry->get('theme_test_template_test_2'), 'Offset was returned correctly from the theme registry'); } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php index 11c845484b94aa55600b59e51a3e2c914bbad230..fffb1752c62b7b05b7721f4c466b153beca8b7c5 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php @@ -397,7 +397,7 @@ public function __construct(ArgumentResolverInterface $argument_resolver, Reques $this->routeMatch = $route_match; $this->moduleHandler = $module_handler; $this->alterInfo('menu_local_actions'); - $this->setCacheBackend($cache_backend, 'local_action_plugins', ['local_action']); + $this->setCacheBackend($cache_backend, 'local_action_plugins'); } } diff --git a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php index ed06974eec193746800ef4242068cb6233cfa9ac..6a072b891c6f8ff06966bd71967b1ff38f820692 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\Render; +use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Render\ElementInfoManager; use Drupal\Core\Theme\ActiveTheme; use Drupal\Tests\UnitTestCase; @@ -46,11 +47,11 @@ class ElementInfoManagerTest extends UnitTestCase { protected $themeManager; /** - * The cache tags invalidator. + * The mocked theme handler. * - * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface|\PHPUnit\Framework\MockObject\MockObject + * @var \Drupal\Core\Extension\ThemeHandlerInterface|\PHPUnit\Framework\MockObject\MockObject */ - protected $cacheTagsInvalidator; + protected $themeHandler; /** * {@inheritdoc} @@ -61,11 +62,11 @@ protected function setUp(): void { parent::setUp(); $this->cache = $this->createMock('Drupal\Core\Cache\CacheBackendInterface'); - $this->cacheTagsInvalidator = $this->createMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface'); + $this->themeHandler = $this->createMock(ThemeHandlerInterface::class); $this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface'); $this->themeManager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface'); - $this->elementInfo = new ElementInfoManager(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager); + $this->elementInfo = new ElementInfoManager(new \ArrayObject(), $this->cache, $this->themeHandler, $this->moduleHandler, $this->themeManager); } /** @@ -90,7 +91,7 @@ public function testGetInfoElementPlugin($plugin_class, $expected_info) { ]); $element_info = $this->getMockBuilder('Drupal\Core\Render\ElementInfoManager') - ->setConstructorArgs([new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager]) + ->setConstructorArgs([new \ArrayObject(), $this->cache, $this->themeHandler, $this->moduleHandler, $this->themeManager]) ->onlyMethods(['getDefinitions', 'createInstance']) ->getMock(); @@ -148,7 +149,7 @@ public function testGetInfoProperty() { ->method('getActiveTheme') ->willReturn(new ActiveTheme(['name' => 'test'])); - $element_info = new TestElementInfoManager(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager); + $element_info = new TestElementInfoManager(new \ArrayObject(), $this->cache, $this->themeHandler, $this->moduleHandler, $this->themeManager); $this->assertSame('baz', $element_info->getInfoProperty('foo', '#bar')); $this->assertNull($element_info->getInfoProperty('foo', '#non_existing_property')); $this->assertSame('qux', $element_info->getInfoProperty('foo', '#non_existing_property', 'qux'));