diff --git a/core/core.services.yml b/core/core.services.yml index 8e19754..14a3bcf 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1095,8 +1095,6 @@ services: arguments: ['@current_user', '@session_handler.write_safe'] current_user: class: Drupal\Core\Session\AccountProxy - calls: - - [setContainer, ['@service_container']] session_configuration: class: Drupal\Core\Session\SessionConfiguration arguments: ['%session.storage.options%'] diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index 6155326..8fe7d05 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -7,8 +7,6 @@ namespace Drupal\Core\Session; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; - /** * A proxied implementation of AccountInterface. * @@ -20,9 +18,7 @@ * allows legacy code to change the current user where the user cannot be * directly injected into dependent code. */ -class AccountProxy implements AccountProxyInterface, ContainerAwareAccountProxyInterface { - - use ContainerAwareTrait; +class AccountProxy implements AccountProxyInterface { /** * The instantiated account. @@ -57,9 +53,9 @@ public function getAccount() { if (!isset($this->account)) { if ($this->initialAccountId) { // After the container is rebuilt, DrupalKernel sets the initial - // account to the id of the logged in user. This is necessary such that - // it is possible to refresh the user account reference here. - $this->account = $this->container->get('entity.manager')->getStorage('user')->load($this->initialAccountId); + // account to the id of the logged in user. This is necessary in order + // to refresh the user account reference here. + $this->account = \Drupal::entityManager()->getStorage('user')->load($this->initialAccountId); } else { $this->account = new AnonymousUserSession(); @@ -179,7 +175,7 @@ public function getLastAccessedTime() { */ public function setInitialAccountId($account_id) { if (isset($this->account)) { - throw new \LogicException('ContainerAwareAccountProxyInterface::setInitialAccountId() cannot be called after an account was set on the AccountProxy'); + throw new \LogicException('AccountProxyInterface::setInitialAccountId() cannot be called after an account was set on the AccountProxy'); } $this->initialAccountId = $account_id; diff --git a/core/lib/Drupal/Core/Session/AccountProxyInterface.php b/core/lib/Drupal/Core/Session/AccountProxyInterface.php index 3de1e2e..7ac9758 100644 --- a/core/lib/Drupal/Core/Session/AccountProxyInterface.php +++ b/core/lib/Drupal/Core/Session/AccountProxyInterface.php @@ -37,4 +37,15 @@ public function setAccount(AccountInterface $account); */ public function getAccount(); + /** + * Sets the id of the initial account. + * + * Never use this method, its sole purpose is to work around weird effects + * during mid-request container rebuilds. + * + * @param int $account_id + * The id of the initial account. + */ + public function setInitialAccountId($account_id); + } diff --git a/core/lib/Drupal/Core/Session/ContainerAwareAccountProxyInterface.php b/core/lib/Drupal/Core/Session/ContainerAwareAccountProxyInterface.php deleted file mode 100644 index 361ab71..0000000 --- a/core/lib/Drupal/Core/Session/ContainerAwareAccountProxyInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -