diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8b28e76..dd0e73a 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1175,7 +1175,7 @@ function comment_load($cid, $reset = FALSE) { * The number of new comments or FALSE if the user is not logged in. */ function comment_num_new($entity_id, $entity_type, $field_name = NULL, $timestamp = 0) { - global $user; + $user = \Drupal::currentUser(); if ($user->isAuthenticated() && \Drupal::moduleHandler()->moduleExists('history')) { // Retrieve the timestamp at which the current user last viewed this entity. diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 5db0830..cff2d83 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -218,11 +218,8 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { $user = \Drupal::currentUser(); - debug($this->status->value); - debug($user->id()); if (!isset($this->status->value)) { $this->status->value = $user->hasPermission('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED; - debug($this->status->value); } if ($this->isNew()) { // Add the comment to database. This next section builds the thread field. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index 627800f..d142924 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -977,6 +977,7 @@ protected function prepareEnvironment() { $request = Request::create('/'); $request->attributes->set('_account', $GLOBALS['user']); $this->container->set('request', $request); + $this->container->set('current_user', $GLOBALS['user']); \Drupal::setContainer($this->container); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php index 99659a7..75b42f4 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php @@ -30,6 +30,7 @@ public static function getInfo() { } public function testUserName() { + $this->drupalLogin($this->users[0]); $view = views_get_view('test_views_handler_field_user_name'); $this->executeView($view); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php b/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php index 0b4df3d..c47ad71 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/UserTestBase.php @@ -41,7 +41,7 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('user_test_views')); - $this->users[] = $this->drupalCreateUser(); + $this->users[] = $this->drupalCreateUser(array('access user profiles')); $this->users[] = user_load(1); $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->id())); $this->nodes[] = $this->drupalCreateNode(array('uid' => 1));