diff --git a/core/lib/Drupal/Core/TempStore/SharedTempStore.php b/core/lib/Drupal/Core/TempStore/SharedTempStore.php index 06973f5c3c..a7078d7f40 100644 --- a/core/lib/Drupal/Core/TempStore/SharedTempStore.php +++ b/core/lib/Drupal/Core/TempStore/SharedTempStore.php @@ -108,18 +108,16 @@ public function __construct(KeyValueStoreExpirableInterface $storage, LockBacken $this->lockBackend = $lock_backend; $this->owner = $owner; $this->requestStack = $request_stack; - if ($current_user instanceof AccountProxyInterface) { - $this->currentUser = $current_user; - } - else { + if (!$current_user instanceof AccountProxyInterface) { @trigger_error('Calling ' . __METHOD__ . '() without the $current_user argument is deprecated in drupal:9.2.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3006268', E_USER_DEPRECATED); - $this->currentUser = \Drupal::currentUser(); if (is_int($current_user)) { // If the $current_user argument is numeric then this object has been // instantiated with the old constructor signature. $expire = $current_user; } + $current_user = \Drupal::currentUser(); } + $this->currentUser = $current_user; $this->expire = $expire; } diff --git a/core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php b/core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php index 151b254f87..3055b04856 100644 --- a/core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php +++ b/core/lib/Drupal/Core/TempStore/SharedTempStoreFactory.php @@ -66,20 +66,16 @@ public function __construct(KeyValueExpirableFactoryInterface $storage_factory, $this->storageFactory = $storage_factory; $this->lockBackend = $lock_backend; $this->requestStack = $request_stack; - if ($current_user instanceof AccountProxyInterface) { - $this->currentUser = $current_user; - } - else { - $this->currentUser = \Drupal::currentUser(); - } - if (!($current_user instanceof AccountProxyInterface)) { + if (!$current_user instanceof AccountProxyInterface) { @trigger_error('Calling ' . __METHOD__ . '() without the $current_user argument is deprecated in drupal:9.2.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3006268', E_USER_DEPRECATED); if (is_int($current_user)) { // If the $current_user argument is numeric then this object has been // instantiated with the old constructor signature. $expire = $current_user; } + $current_user = \Drupal::currentUser(); } + $this->currentUser = $current_user; $this->expire = $expire; }