Skip to:

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#2806 closed defect (fixed)

bbp_get_topic_last_reply_id() returns the topic id when the topic does not have any replies

Reported by: netweb Owned by: johnjamesjacoby
Milestone: 2.6 Priority: high
Severity: normal Version:
Component: Component - Topics Keywords: 2nd-opinion has-patch


// Create a forum
$forum_id = bbp_insert_forum( array(
	'post_title'   => 'forum_title',
	'post_content' => 'forum_content'
) );

// Create a topic
$topic_id = bbp_insert_topic( array(
	'post_title'   => 'topic_title',
	'post_content' => 'topic_content'
) );
var_dump( $forum_id );
var_dump( bbp_get_forum_last_topic_id( $forum_id ) );
var_dump( $topic_id );
var_dump( bbp_get_topic_last_reply_id( $topic_id ) );

Returns: int(59) int(0) int(60) int(60)
Expected: int(59) int(0) int(60) int(0)

Both functions create their correct meta values _bbp_last_topic_id and _bbp_last_reply_id with value 0

Attachments (1)

2806.diff (2.0 KB) - added by netweb 5 years ago.

Download all attachments as: .zip

Change History (6)

5 years ago

#1 @netweb
5 years ago

  • Keywords has-patch added

Patch includes a fix and unit test documenting the issue.

Note: Need to consider a better file name, file location and function name for the included unit tests ;)

#2 @johnjamesjacoby
5 years ago

This might break other things upstream, specifically single topics where both topics and replies are in the same loop, and the topic does not have any replies.

#3 @johnjamesjacoby
5 years ago

In 5842:

IDs: Some reply functions still default to their topics if no replies are present. This functionality has slowly been removed over time and built into respective functions. In this changeset, we remove those leftover assignments and update a few phpdoc descriptions as needed.

Hat-tip netweb. See #2806.

#4 @johnjamesjacoby
5 years ago

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

In 5844:

Add unit test for last topic & reply ID's for topics & forums. Fixes #2806. Props netweb.

#5 @netweb
5 years ago

In 5872:

Tests: Include bbp_get_forum_last_reply_id() assertions in test_bbp_get_forum_and_topic_last_topic_id_and_last_reply_id() missed in r5844

See #2806

Note: See TracTickets for help on using tickets.