diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index cb6fbd2..4a9dd05 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -111,7 +111,9 @@ public function getAccount() { public function impersonateAccount(AccountInterface $account) { // Prevent session information from being saved and push the previous account. array_push($this->accountStack, $this->account); - $this->originalSessionSaving = $this->sessionManager->isEnabled(); + if (!isset($this->originalSessionSaving)) { + $this->originalSessionSaving = $this->sessionManager->isEnabled(); + } $this->sessionManager->disable(); $this->setAccount($account); return $this; diff --git a/core/lib/Drupal/Core/Session/AccountProxyInterface.php b/core/lib/Drupal/Core/Session/AccountProxyInterface.php index 3c3f072..b88ba0b 100644 --- a/core/lib/Drupal/Core/Session/AccountProxyInterface.php +++ b/core/lib/Drupal/Core/Session/AccountProxyInterface.php @@ -49,6 +49,9 @@ public function impersonateAccount(AccountInterface $account); * * @return \Drupal\Core\Session\AccountInterface * $this. + * + * @throws \RuntimeException + * When there are no more account impersonations to revert. */ public function revertAccount(); @@ -60,6 +63,9 @@ public function revertAccount(); * * @return \Drupal\Core\Session\AccountInterface * $this. + * + * @throws \RuntimeException + * When there are no more account impersonations to revert. */ public function revertAll(); }