Opened 7 weeks ago
Last modified 3 weeks ago
#3637 assigned defect (bug)
Forum with subforums update the last topic incorrectly
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | major | Version: | 2.6.13 |
Component: | Component - Forums | Keywords: | has-patch |
Cc: |
Description
When a forum only has subforums, it will always consider only the last subforum when selecting the latest topic. This is because the bbp_update_forum_last_topic_id()
function does not properly find and update the $children_last_topic
when looping through all subforums:
Loop through children and add together forum reply counts
$children = bbp_forum_query_subforum_ids( $forum_id );
if ( ! empty( $children ) ) {
foreach ( $children as $child ) {
$children_last_topic = bbp_update_forum_last_topic_id( $child ); Recursive
}
}
$children_last_topic
will always find the latest topic ID of the final subforum, when in actuality, it should also be comparing the last topic of all forums and picking the latest one of all of them:
Loop through children and add together forum reply counts
$children = bbp_forum_query_subforum_ids( $forum_id );
if ( ! empty( $children ) ) {
We want to record the last active time.
$latest_last_active = PHP_INT_MIN;
foreach ( $children as $child ) {
$child_last_topic = bbp_update_forum_last_topic_id( $child ); Recursive.
If the response is invalid.
if(!empty($child_last_topic)) {
We need to get the last active time, because we need to compare them.
$child_last_active = bbp_get_topic_last_active_time($child_last_topic);
Update the last topic only if it is later.
if($child_last_active > $latest_last_active) {
$latest_last_active = $child_last_active;
$children_last_topic = $child_last_topic;
}
}
}
}
The code didn't render properly. This is where the problem is (first block of code):
And this is the edited one: