Skip to:
Content

bbPress.org

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2845 closed enhancement (fixed)

Add unit tests for bbp_reply_position() and bbp_get_reply_url()

Reported by: netweb's profile netweb Owned by: netweb's profile netweb
Milestone: 2.6 Priority: normal
Severity: normal Version: 2.1
Component: Component - Replies Keywords: has-patch
Cc:

Description

When adding add_filter( 'bbp_show_lead_topic', '__return_true' ); reply's positions are incorrect

Added in r3940:

// Bump the position by one if the lead topic is in the replies loop 
if ( ! bbp_show_lead_topic() ) 
	$reply_position++; 

It should only bump the reply position when bbp_show_lead_topic() is true, not false or not defined

// Bump the position by one if the lead topic is in the replies loop 
if ( bbp_show_lead_topic() ) 
	$reply_position++; 

Attachments (1)

2845.diff (2.8 KB) - added by netweb 9 years ago.

Download all attachments as: .zip

Change History (4)

@netweb
9 years ago

#1 @netweb
9 years ago

  • Keywords 2nd-opinion removed
  • Summary changed from Incorrect reply position when using bbp_show_lead_topic() to Add unit tests for bbp_reply_position() and bbp_get_reply_url()
  • Type changed from defect to enhancement

A topics reply loop is paginated based on the bbp_get_replies_per_page() value:

  • Default: Each reply position is bumped by 1, this is because the topic is included in the reply loop, by default this is 15 posts per page, 14 replies and the 1 topic, each subsequent page is then 15 replies.
  • Using bbp_show_lead_topic() reply positions are accurate per the stored menu_order of a repliy in wp-posts, as such the topic is not included in the reply loop, each page will by default include 15 replies and the 1 topic.

Note: Repurposing this ticket just for unit tests as there is nothing actually wrong in the code

#2 @netweb
9 years ago

  • Owner set to netweb
  • Resolution set to fixed
  • Status changed from new to closed

In 5894:

Replies: Clarify inline doc surrounding bbp_show_lead_topic() in bbp_get_reply_position()

This changest clarify's the docs on how bbp_show_lead_topic() affects a reply's menu order in a topics reply loop and determining the correct pagination of reply URL's.

Includes unit tests for bbp_reply_position() and bbp_get_reply_url()

Fixes #2845

#3 @netweb
9 years ago

In 5896:

Tests: If we add filters in tests, we need to also remove them for WordPress < 4.0 compatability

Props thebrandonallen. See #2845

Note: See TracTickets for help on using tickets.