diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 27ff7c3..84a5833 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1590,11 +1590,33 @@ function comment_num_new($nid, $timestamp = 0) { $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT); // Use the timestamp to retrieve the number of new comments. - return db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array( + $new = db_query('SELECT COUNT(cid) FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array( ':nid' => $nid, ':timestamp' => $timestamp, ':status' => COMMENT_PUBLISHED, ))->fetchField(); + // Obtain cid to exclude new and edited for the same comment. + $new_cid = db_query('SELECT * FROM {comment} WHERE nid = :nid AND created > :timestamp AND status = :status', array( + ':nid' => $nid, + ':timestamp' => $timestamp, + ':status' => COMMENT_PUBLISHED, + )); + // A comment edited also is marked like new comment. + $query = db_select('comment', 'c'); + $query->condition('c.changed', 'c.created', '>') + ->condition('c.changed', $timestamp, '>=') + ->condition('c.nid', $nid, '=') + ->condition('c.status', COMMENT_PUBLISHED, '=') + ->fields('c', array('cid', 'nid')); + // Add each new comment to exclude from new comments. + foreach ($new_cid as $record) { + $query->condition('c.cid', $record->cid, '<>'); + } + $edited = $query->countQuery() + ->execute() + ->fetchField(); + + return $new + $edited; } else { return FALSE; diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index cead0cd..9bb28a8 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -63,7 +63,6 @@ public function form(array $form, array &$form_state, EntityInterface $comment) if ($is_admin) { $author = (!$comment->uid && $comment->name ? $comment->name : $comment->registered_name); $status = (isset($comment->status) ? $comment->status : COMMENT_NOT_PUBLISHED); - $date = (!empty($comment->date) ? $comment->date : format_date($comment->created, 'custom', 'Y-m-d H:i O')); } else { if ($user->uid) { @@ -73,7 +72,10 @@ public function form(array $form, array &$form_state, EntityInterface $comment) $author = ($comment->name ? $comment->name : ''); } $status = (user_access('skip comment approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED); - $date = ''; + } + $date = ''; + if (!empty($comment->cid)) { + $date = (!empty($comment->date) ? $comment->date : format_date($comment->created, 'custom', 'Y-m-d H:i O')); } // Add the author name field depending on the current user.