core/modules/comment/src/CommentForm.php | 6 ------ core/modules/node/src/Tests/Views/FrontPageTest.php | 7 ++++--- .../system/src/Tests/Cache/PageCacheTagsIntegrationTest.php | 2 ++ core/modules/views/src/Tests/GlossaryTest.php | 3 ++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 3e1ffd9..95629b2 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -94,12 +94,6 @@ public function form(array $form, FormStateInterface $form_state) { $form['#attributes']['data-user-info-from-browser'] = TRUE; } - // Vary per role, because we check a permission above and attach an asset - // library only for authenticated users. - // @todo: change to 'user.roles:authenticated' once - // https://www.drupal.org/node/2432837 lands. - $form['#cache']['contexts'][] = 'user.roles'; - // If not replying to a comment, use our dedicated page callback for new // Comments on entities. if (!$comment->id() && !$comment->hasParentComment()) { diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php index 61fe5eb..43632d7 100644 --- a/core/modules/node/src/Tests/Views/FrontPageTest.php +++ b/core/modules/node/src/Tests/Views/FrontPageTest.php @@ -241,7 +241,7 @@ protected function assertFrontPageViewCacheTags($do_assert_views_caches) { $view = Views::getView('frontpage'); $view->setDisplay('page_1'); - $cache_contexts = ['node_view_grants', 'language']; + $cache_contexts = ['node_view_grants', 'language', 'user.roles']; // Test before there are any nodes. $empty_node_listing_cache_tags = [ @@ -257,7 +257,7 @@ protected function assertFrontPageViewCacheTags($do_assert_views_caches) { $this->assertPageCacheContextsAndTags( Url::fromRoute('view.frontpage.page_1'), $cache_contexts, - Cache::mergeTags($empty_node_listing_cache_tags, ['rendered']) + Cache::mergeTags($empty_node_listing_cache_tags, ['config:user_role_list', 'rendered']) ); // Create some nodes on the frontpage view. Add more than 10 nodes in order @@ -317,7 +317,7 @@ protected function assertFrontPageViewCacheTags($do_assert_views_caches) { $this->assertPageCacheContextsAndTags( Url::fromRoute('view.frontpage.page_1'), $cache_contexts, - Cache::mergeTags($first_page_output_cache_tags, ['rendered']) + Cache::mergeTags($first_page_output_cache_tags, ['config:user_role_list', 'rendered']) ); // Second page. @@ -329,6 +329,7 @@ protected function assertFrontPageViewCacheTags($do_assert_views_caches) { 'node:4', 'node:5', // The rest. + 'config:user_role_list', 'config:filter.format.plain_text', 'config:views.view.frontpage', 'node_list', diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php index f4d30ec..7e41e7f 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -101,6 +101,7 @@ function testPageCacheTags() { 'config:system.menu.footer', 'config:system.menu.main', 'config:system.site', + 'config:user_role_list', )); // Full node page 2. @@ -130,6 +131,7 @@ function testPageCacheTags() { 'comment_list', 'node_list', 'config:views.view.comments_recent', + 'config:user_role_list', )); } diff --git a/core/modules/views/src/Tests/GlossaryTest.php b/core/modules/views/src/Tests/GlossaryTest.php index fd97978..472ba04 100644 --- a/core/modules/views/src/Tests/GlossaryTest.php +++ b/core/modules/views/src/Tests/GlossaryTest.php @@ -87,7 +87,8 @@ public function testGlossaryView() { // Verify cache tags. $this->enablePageCaching(); - $this->assertPageCacheContextsAndTags(Url::fromRoute('view.glossary.page_1'), ['cache.context.url', 'node_view_grants', 'language', 'user'], [ + $this->assertPageCacheContextsAndTags(Url::fromRoute('view.glossary.page_1'), ['cache.context.url', 'node_view_grants', 'language', 'user', 'user.roles'], [ + 'config:user_role_list', 'config:views.view.glossary', 'node:' . $nodes_by_char['a'][0]->id(), 'node:' . $nodes_by_char['a'][1]->id(), 'node:' . $nodes_by_char['a'][2]->id(), 'node_list',