From edd0191d896d29a070cec009a5133e8ef7dd8766 Mon Sep 17 00:00:00 2001
From: Lee Rowlands <lee.rowlands@previousnext.com.au>
Date: Thu, 7 Mar 2019 19:12:45 +1000
Subject: [PATCH] Revert "Issue #2135445 by dww, Sam152, jessebeach, Mile23,
 Kristen Pol, Wim Leers, larowlan: Toolbar displays Manage tab even if the
 user is not permitted to see it"

This reverts commit 211c6641f86d5e9c3e4c9cee267bf44f8bf23a05.
---
 .../SettingsTrayBlockFormTest.php               |  1 -
 .../src/Functional/ToolbarAdminMenuTest.php     | 17 -----------------
 .../ToolbarIntegrationTest.php                  |  1 -
 core/modules/toolbar/toolbar.module             | 12 ------------
 4 files changed, 31 deletions(-)

diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
index bd23c50a4c3a..d505a0befcb3 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
@@ -30,7 +30,6 @@ protected function setUp() {
 
     $user = $this->createUser([
       'administer blocks',
-      'access administration pages',
       'access contextual links',
       'access toolbar',
       'administer nodes',
diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
index cd0dd2d72dfb..9585c86eb4a1 100644
--- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
+++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
@@ -394,23 +394,6 @@ public function testExternalLink() {
     $this->assertRaw('title="External URL &amp; escaped"');
   }
 
-  /**
-   * Tests that there is no Manage tab in the Toolbar for authenticated users.
-   *
-   * The authorized user should not have a Manage tab simply with the 'access
-   * toolbar' permission. They need 'access administration pages' for that.
-   */
-  public function testEmptyMenuTray() {
-    // Log out the admin user because we're testing restricted access.
-    $this->drupalLogout();
-    $this->drupalLogin($this->drupalCreateUser(['access toolbar']));
-    $this->assertResponse(200);
-    // @todo The toolbar div itself still has the id "toolbar-administration".
-    // @see https://www.drupal.org/project/drupal/issues/1044090
-    $this->assertSession()->elementExists('css', 'div[id=toolbar-administration]');
-    $this->assertSession()->elementNotExists('css', 'a[id=toolbar-item-administration]');
-  }
-
   /**
    * Get the hash value from the admin menu subtrees route path.
    *
diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
index c3cda9174c14..fd163985e750 100644
--- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
+++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
@@ -22,7 +22,6 @@ class ToolbarIntegrationTest extends WebDriverTestBase {
   public function testToolbarToggling() {
     $admin_user = $this->drupalCreateUser([
       'access toolbar',
-      'access administration pages',
       'administer site configuration',
       'access content overview',
     ]);
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index a52c85cc09e0..7df073fe60f0 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -159,18 +159,6 @@ function toolbar_toolbar() {
     '#weight' => -20,
   ];
 
-  // If the current user cannot access administration pages, we can save a large
-  // amount of unnecessary work by ending here. It'd be better to actually know
-  // if the admin menu tree is empty for them, but trying to load that tree only
-  // happens in a #pre_render callback, and at that point, it's too late. The
-  // entire toolbar is rendered with the 'user.permissions' #cache context, so
-  // we can safely do this here and it'll still be cached correctly.
-  // @see toolbar_prerender_toolbar_administration_tray()
-  // @see toolbar_page_top()
-  if (!\Drupal::currentUser()->hasPermission('access administration pages')) {
-    return $items;
-  }
-
   // To conserve bandwidth, we only include the top-level links in the HTML.
   // The subtrees are fetched through a JSONP script that is generated at the
   // toolbar_subtrees route. We provide the JavaScript requesting that JSONP
-- 
GitLab