Skip to:
Content

bbPress.org

Opened 3 months ago

Last modified 3 months ago

#3611 new defect (bug)

Wrong Output on Hidden Topic Counting Function

Reported by: sirlouen's profile SirLouen Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
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 3 months ago.
Fix for Hiddent Topic Count

Download all attachments as: .zip

Change History (3)

@SirLouen
3 months ago

Fix for Hiddent Topic Count

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


3 months ago
#1

Note: See TracTickets for help on using tickets.