Repository navigation
Conversation
…plies Requests like /topic/<slug>/page/45/ on a topic with one page of replies returned a 200 with only the lead post. Count the pages the same way bbp_get_topic_pagination() does, adding hidden replies when viewing all replies, and set a 404 when the requested page is beyond them. Moderators are skipped: their reply loop also includes topic reports, which no stored count tracks. See https://meta.trac.wordpress.org/ticket/4412
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes https://meta.trac.wordpress.org/ticket/4412
A request for a topic page past its last page of replies, like
/support/topic/<slug>/page/45/on a topic with one page of replies, returns a 200 with only the lead post. It should be a 404.Nothing checks the page number against the topic.
bbp_has_replies()runs the reply query for any page and simply finds no replies, andWPORG_Page_Limiteronly stops pages above 49 for logged-out users.This adds a check on
bbp_template_redirect, next toredirect_page_zero_one(). On a single topic withpagedabove 1, it counts the pages the same waybbp_get_topic_pagination()does (public reply count, plus the topic when it is part of the reply loop) and adds the hidden reply count when the user is viewing all replies (bbp_get_view_all( 'edit_others_replies' )), which is whenbbp_has_replies()includes them. A page past that count getsbbp_set_404(). Threaded topics are skipped, asbbp_get_topic_pagination()skips them. Users with themoderatecapability are skipped too:Report_Topic::maybe_include_reports()addsreported_topicsposts to their reply loop, and no stored count includes those, so a report could push a real page past the count.?view=allgets page 2 with the pending repliesTesting
npm run support:env startinenvironments/. (On Docker Desktop this currently fails on thewporg-ratings.phpmount; Environments: Fix jobs, WordPress.tv and Support Forums envs failing to start #1205 fixes that.)/topic/<slug>/page/9/. It returns a 404 and shows the 404 page./topic/<slug>/page/2/. It returns a 200 with the last 5 replies.A Playwright run against the local environment failed on trunk with
Expected: 404 Received: 200(3 failed, 4 passed) and passes with this change (7 passed).AI assistance: Yes. Tool: Claude Code. Used for: finding the cause and drafting the change; I reviewed and tested it myself.
Summary by CodeRabbit