Commit 46a9a495 authored by alexpott's avatar alexpott

Issue #2296839 by MKorostoff, er.pushpinderrana | YesCT: Remove deprecated comment_num_new().

parent 1793df6d
......@@ -891,29 +891,6 @@ function comment_user_predelete($account) {
entity_delete_multiple('comment', $cids);
}
/**
* Gets the number of new comments for the current user and the specified node.
*
* @param int $entity_id
* Entity ID of the entity to which the comments are attached.
* @param string $entity_type
* Entity type of the entity to which the comments are attached.
* @param string $field_name
* (optional) The field_name to count comments for. Defaults to NULL.
* @param $timestamp
* Time to count from (defaults to time of last user access to node).
*
* @return int|false
* The number of new comments or FALSE if the user is not logged in.
*
* @deprecated Deprecated since Drupal 8.x-dev, to be removed in Drupal 8.0.
* Use \Drupal\comment\CommentManager::getCountNewComments().
*/
function comment_num_new($entity_id, $entity_type, $field_name = NULL, $timestamp = 0) {
$entity = \Drupal::entityManager()->getStorage($entity_type)->load($entity_id);
return \Drupal::service('comment.manager')->getCountNewComments($entity, $field_name, $timestamp);
}
/**
* Gets the display ordinal for a comment, starting from 0.
*
......
......@@ -231,7 +231,8 @@ function assertCommentLinks(array $info) {
// For logged in users, a link containing the amount of new/unread
// comments is expected.
// See important note about comment_num_new() below.
// See important note about
// \Drupal::service('comment.manager')->getCountNewComments() below.
if ($this->loggedInUser && isset($this->comment) && !isset($this->comment->seen)) {
$this->assertLink(t('1 new comment'));
$this->comment->seen = TRUE;
......@@ -243,9 +244,9 @@ function assertCommentLinks(array $info) {
$this->assertNoLink(t('1 comment'));
$this->assertNoLink(t('1 new comment'));
}
// comment_num_new() is based on node views, so comments are marked as
// read when a node is viewed, regardless of whether we have access to
// comments.
// \Drupal::service('comment.manager')->getCountNewComments() is based on
// node views, so comments are marked as read when a node is viewed,
// regardless of whether we have access to comments.
if ($path == "node/$nid" && $this->loggedInUser && isset($this->comment)) {
$this->comment->seen = TRUE;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment