diff --git a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php index cbfc68c..ff914f3 100644 --- a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php +++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php @@ -104,7 +104,8 @@ protected function debugCacheTags(array $actual_tags, array $expected_tags) { * (optional) Whether the default cache tags should be included. */ protected function assertCacheTags(array $expected_tags, $include_default_tags = TRUE) { - if ($include_default_tags) { + // The anonymous role cache tag is only added if the user is anonymous. + if ($include_default_tags && \Drupal::currentUser()->isAnonymous()) { $expected_tags = Cache::mergeTags($expected_tags, ['config:user.role.anonymous']); } $actual_tags = $this->getCacheHeaderValues('X-Drupal-Cache-Tags'); @@ -129,7 +130,13 @@ protected function assertCacheTags(array $expected_tags, $include_default_tags = */ protected function assertCacheContexts(array $expected_contexts, $message = NULL, $include_default_contexts = TRUE) { if ($include_default_contexts) { - $expected_contexts = Cache::mergeContexts($expected_contexts, ['languages:language_interface', 'theme', 'user.permissions']); + $default_contexts = ['languages:language_interface', 'theme']; + // Add the user.permission context to the list of default contexts except + // when user is already there. + if (!in_array('user', $expected_contexts)) { + $default_contexts[] = 'user.permissions'; + } + $expected_contexts = Cache::mergeContexts($expected_contexts, $default_contexts); } $actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts'); diff --git a/core/modules/user/src/Plugin/views/argument/RolesRid.php b/core/modules/user/src/Plugin/views/argument/RolesRid.php index 75fff0c..7fd209d 100644 --- a/core/modules/user/src/Plugin/views/argument/RolesRid.php +++ b/core/modules/user/src/Plugin/views/argument/RolesRid.php @@ -50,7 +50,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return parent::create($container, $configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')); + return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')); } /**