Skip to:
Content

bbPress.org

Opened 4 years ago

Closed 4 years ago

Last modified 4 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
Cc:

Description

// 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

https://bbpress.trac.wordpress.org/browser/trunk/src/includes/forums/template.php?annotate=blame#L891
https://bbpress.trac.wordpress.org/browser/trunk/src/includes/topics/template.php?annotate=blame#L2018

Attachments (1)

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

Download all attachments as: .zip

Change History (6)

@netweb
4 years ago

#1 @netweb
4 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
4 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
4 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
4 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
4 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.