Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

little "bug" class HasNew

This discussion is related to the Vanilla addon.
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

askee
Sign In or Register to comment.