diff --git a/core/modules/comment/comment.services.yml b/core/modules/comment/comment.services.yml index 5a8051d..e217aef 100644 --- a/core/modules/comment/comment.services.yml +++ b/core/modules/comment/comment.services.yml @@ -13,4 +13,4 @@ services: comment.manager: class: Drupal\comment\CommentManager - arguments: ['@field.info', '@entity.manager', '@database', '@module_handler', '@current_user'] + arguments: ['@field.info', '@entity.manager', '@database', '@module_handler'] diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 6d59775..1d1fa8b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityManager; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Session\AccountInterface; /** * Comment manager contains common functions to manage comment fields. @@ -48,13 +47,6 @@ class CommentManager { protected $moduleHandler; /** - * The current user service. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $currentUser; - - /** * Construct the CommentManager object. * * @param \Drupal\field\FieldInfo $field_info @@ -62,12 +54,11 @@ class CommentManager { * @param \Drupal\Core\Entity\EntityManager $entity_manager * The entity manager service. */ - public function __construct(FieldInfo $field_info, EntityManager $entity_manager, Connection $connection, ModuleHandlerInterface $module_handler, AccountInterface $current_user) { + public function __construct(FieldInfo $field_info, EntityManager $entity_manager, Connection $connection, ModuleHandlerInterface $module_handler) { $this->fieldInfo = $field_info; $this->entityManager = $entity_manager; $this->connection = $connection; $this->moduleHandler = $module_handler; - $this->currentUser = $current_user; } /** @@ -285,7 +276,7 @@ public function getFieldUIPageTitle($field_name) { * The number of new comments or FALSE if the user is not logged in. */ public function countNewComments($entity_id, $entity_type, $field_name = NULL, $timestamp = 0) { - if ($this->currentUser->isAuthenticated() && $this->moduleHandler->moduleExists('history')) { + if (\Drupal::currentUser()->isAuthenticated() && $this->moduleHandler->moduleExists('history')) { // Retrieve the timestamp when the current user last viewed this entity. if (!$timestamp) { if ($entity_type == 'node') { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 451831a..56840fc 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -108,6 +108,7 @@ function testCommentTokenReplacement() { foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input))); + if ($output != $expected) $this->fail("output $output != expected $expected"); } } }