HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

little "bug" class HasNew

jackmaessenjackmaessen ✭✭✭
edited November 2015 in Feedback

In applications/vanilla/views/discussions/helper_functions.php you can see this function about line 231

function NewComments($Discussion) {
   if (!Gdn::Session()->IsValid())
      return '';

   if ($Discussion->CountUnreadComments === TRUE) {
      $Title = htmlspecialchars(T("You haven't read this yet."));

      return ' <strong class="HasNew JustNew NewCommentCount" title="'.$Title.'">'.T('new discussion', 'new').'</strong>';
   } elseif ($Discussion->CountUnreadComments > 0) {
      $Title = htmlspecialchars(Plural($Discussion->CountUnreadComments, "%s new comment since you last read this.", "%s new comments since you last read this."));

      return ' <strong class="HasNew NewCommentCount" title="'.$Title.'">'.Plural($Discussion->CountUnreadComments, '%s new', '%s new plural', BigPlural($Discussion->CountUnreadComments, '%s new', '%s new plural')).'</strong>';
   return '';

On line 5 above you can see there is no check for the user who has started the topic in CountUnreadComments.
The user now gets his own topic as New Topic.
I fixed it by changing line 5 to this line:

if ($Discussion->CountUnreadComments === TRUE && $Discussion->InsertUserID != Gdn::Session()->UserID) { // exclude the topic starter from CountUnreadComments

Sign In or Register to comment.