From 66239988f788f1a373347ad50280085d64341e7f Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Thu, 10 Oct 2013 11:39:06 -0700
Subject: [PATCH] Revert "Issue #2105123 by pwolanin: Add a currentUser()
 method to \Drupal\Core\Plugin\PluginBase."

Needs more discussion.

This reverts commit feaee01eafc38b43352dbeb8a536db35f2103b26.
---
 core/lib/Drupal/Core/Plugin/PluginBase.php    | 19 -------------------
 .../Drupal/user/Plugin/Search/UserSearch.php  |  2 +-
 2 files changed, 1 insertion(+), 20 deletions(-)

diff --git a/core/lib/Drupal/Core/Plugin/PluginBase.php b/core/lib/Drupal/Core/Plugin/PluginBase.php
index 246ddaadbaa5..03f952a6426d 100644
--- a/core/lib/Drupal/Core/Plugin/PluginBase.php
+++ b/core/lib/Drupal/Core/Plugin/PluginBase.php
@@ -22,25 +22,6 @@ abstract class PluginBase extends ComponentPluginBase {
    */
   protected $translationManager;
 
-  /**
-   * Current user object.
-   *
-   * @var \Drupal\Core\Session\AccountInterface
-   */
-  protected $currentUser;
-
-  /**
-   * Gets the current active user.
-   *
-   * @return \Drupal\Core\Session\AccountInterface
-   */
-  protected function currentUser() {
-    if (!$this->currentUser) {
-      $this->currentUser = \Drupal::currentUser();
-    }
-    return $this->currentUser;
-  }
-
   /**
    * Translates a string to the current language or to a given language.
    *
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php
index ee1d590c7634..52ed50b07a39 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php
@@ -120,7 +120,7 @@ public function execute() {
       ->select('users')
       ->extend('Drupal\Core\Database\Query\PagerSelectExtender');
     $query->fields('users', array('uid'));
-    $user_account = $this->currentUser();
+    $user_account = $this->request->attributes->get('_account');
     if ($user_account->hasPermission('administer users')) {
       // Administrators can also search in the otherwise private email field, and
       // they don't need to be restricted to only active users.
-- 
GitLab