Skip to:
Content

bbPress.org

Opened 16 months ago

Closed 8 months ago

Last modified 4 months ago

#3611 closed defect (bug) (fixed)

Wrong Output on Hidden Topic Counting Function

Reported by: sirlouen's profile SirLouen Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6.14 Priority: normal
Severity: normal Version: 2.0
Component: Component - Forums Keywords: has-patch has-unit-tests
Cc:

Description

I was reviewing this test case

<?php
$count = bbp_get_forum_topic_count_hidden( $f, true );
$this->assertSame( 1, $count );

Which happens to be failing.

After inspection of the function bbp_get_forum_topic_count_hidden

I've noted that the metakey _bbp_topic_reply_count_hidden is not being used anywhere, hence its never initialized in the $topic_total_count @ bbp_bump_forum_topic_count_hidden

This can be something legacy, so essentially judging by the code, I think that _bbp_topic_reply_count_hidden was substituted by _bbp_total_topic_count_hidden which make a lot of sense because the condition is

<?php
$meta_key = empty( $total_count ) ? '_bbp_topic_count_hidden' : '_bbp_total_topic_count_hidden';

Which happens to be checking if total_count is true, then its false, hence return the "total count" metakey.

Also, with this patch, the current available Unit Test passes.

Also, given that total_count is a bool, why not use the not operator instead of empty. It's the same, but using the later, to my eyes looks a little less intuitive.

Attachments (1)

hidden-count-fix.patch (784 bytes) - added by SirLouen 16 months ago.
Fix for Hiddent Topic Count

Download all attachments as: .zip

Change History (7)

@SirLouen
16 months ago

Fix for Hiddent Topic Count

This ticket was mentioned in PR #19 on bbpress/bbPress by @SirLouen.


16 months ago
#1

#3 @johnjamesjacoby
8 months ago

  • Milestone changed from Awaiting Review to 2.6.14
  • Owner set to johnjamesjacoby
  • Status changed from new to assigned
  • Version changed from trunk to 2.0

#4 @johnjamesjacoby
8 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 7330:

Forums: fix meta-key typo in bbp_get_forum_topic_count_hidden()

This change replaces _bbp_topic_reply_count_hidden with _bbp_total_topic_count_hidden which is the intended name of the meta-key.

Props sirlouen.

In trunk, for 2.7.

Fixes #3611.

#5 @johnjamesjacoby
8 months ago

In 7331:

Forums: fix meta-key typo in bbp_get_forum_topic_count_hidden()

This change replaces _bbp_topic_reply_count_hidden with _bbp_total_topic_count_hidden which is the intended name of the meta-key.

Props sirlouen.

In branches/2.6, for 2.6.14.

Fixes #3611.

Note: See TracTickets for help on using tickets.