Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

[FIX] Post total off by 1 in Vanilla 2.1.11

ozonorojoozonorojo
edited June 2015 in Vanilla 2.0 - 2.8

While testing the PostNum plugin in Vanilla 2.1.11 I noticed the total count of posts displayed is one unit short of the real value. For instance, in a discussion with 3 posts (original post plus 2 comments) it will show "Post 2 of 2" and "Post 3 of 2".

The fix is straightforward: add a "+1" to the value calculated, at the end of line 64:

$Total = $Object->CountComments + 1 ;

This in turn allows for cleaning up the logic a bit. The original "if" block (lines 60 to 74) can be substituted for this:

if (get_class($Sender) == 'DiscussionController') {
    $Object = $Sender->Data['Discussion'];
} else {
    $Object = $Sender->Discussion;
}
$Total = $Object->CountComments + 1;
$postID = 'Post '.$Offset.' of '.$Total;

Comments

  • Options

    In case someone doesn't feel comfortable manually editing the code, here is the fixed version. Unzip and overwrite the original.

Sign In or Register to comment.