Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Topic paging issue


_ck_
Participant

@_ck_

You know what, this is an inherit flaw with bbpress that I think I mentioned elsewhere years ago.

It never recalculates post-position when there are deleted posts, yet it relies on that post-position to find a specific posts’s page.

See this is how it calculates the page

function get_post_link( $post_id = 0 ) {
$bb_post = bb_get_post( get_post_id( $post_id ) );
>>>>>> $page = bb_get_page_number( $bb_post->post_position );
return apply_filters( 'get_post_link', get_topic_link( $bb_post->topic_id, $page ) . "#post-$bb_post->post_id", $bb_post->post_id );
}

and this is how it calculates that page

return intval( ceil( $item / $per_page ) );

so it’s $bb_post->post_position / $per_page

always, regardless if there are deleted posts in the way, which is why it can be “short” when calculating the last page(s) on a longer topic with deleted posts.

The solution is that post-position has to be recalculated when a post is deleted. The only side effect is that for admin, jumping directly to a deleted post would not work, you’d have to find it manually.

bbPress never, ever, re-calculates post-position, even on a recount, if I am not mistaken.

There is one tiny work-around we can do.

For the LAST POST calculation, we can intercept that and subtract the number of deleted posts from the post-position. Hmm, actually wait, is it subtract or add. I have to investigate this a bit and think out the logic.

Skip to toolbar