commit 96d89481501e3fc0c13ef0e75c8c6b7545df122e Author: Joel Pittet Date: Sat Jul 19 10:36:14 2014 -0700 tweaks from #47 diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index c056ccd..6d5998b 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -1250,13 +1250,8 @@ protected function drupalStaticReset($name = NULL) { * @return \Drupal\Core\Session\AccountInterface */ protected function currentUser() { - if (!$this->currentUser) { - if (\Drupal::hasService('current_user')) { - $this->currentUser = \Drupal::currentUser(); - } - else { - $this->currentUser = \Drupal::currentUser(); - } + if (!$this->currentUser && \Drupal::hasService('current_user')) { + $this->currentUser = \Drupal::currentUser(); } return $this->currentUser; } diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php index c770b41..4545c19 100644 --- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php +++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php @@ -138,7 +138,7 @@ public function cleanup(Request $request) {} */ public function handleException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); - if (\Drupal::currentUser()->isAnonymous() && $exception instanceof AccessDeniedHttpException) { + if ($GLOBALS['user']->isAnonymous() && $exception instanceof AccessDeniedHttpException) { if (!$this->applies($event->getRequest())) { $site_name = $this->configFactory->get('system.site')->get('name'); global $base_url; diff --git a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php index 184b395..38b6fb3 100644 --- a/core/modules/history/src/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/src/Tests/Views/HistoryTimestampTest.php @@ -43,7 +43,7 @@ public function testHandlers() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); - \Drupal::getContainer()->set('current_user', $account); + \Drupal::currentUser()->setCurrentUser($account); db_insert('history') ->fields(array( diff --git a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php index cf6f5f2..4a16236 100644 --- a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php +++ b/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php @@ -31,14 +31,14 @@ public function test_plugin_argument_default_current_user() { $this->drupalLogin($account); $admin = \Drupal::currentUser(); $session_manager = \Drupal::service('session_manager')->disable(); - \Drupal::getContainer()->set('current_user', $account); + \Drupal::currentUser()->setCurrentUser($account); $view = Views::getView('test_plugin_argument_default_current_user'); $view->initHandlers(); $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.'); // Switch back. - \Drupal::getContainer()->set('current_user', $admin); + \Drupal::currentUser()->setCurrentUser($admin); $session_manager->enable(); }