Repository navigation
Conversation
bbPress turns off redirect_canonical() on paginated single topics, so /topic/<slug>/page/2 answered with a 200 instead of a redirect. Send a 301 to the user_trailingslashit() form of the path, keeping the query string. See https://meta.trac.wordpress.org/ticket/5322
|
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/5322
/support/topic/<slug>/page/2(no trailing slash) returns a 200 instead of a 301 to/support/topic/<slug>/page/2/.Core's
redirect_canonical()would add the slash, but bbPress turns it off on paginated single topics:bbp_do_not_redirect_paginations()on thebbp_redirect_canonicalfilter returns an empty URL whenbbp_get_paged()is above 1 on a single topic. So nothing adds the slash on page 2 and later. The topic URL itself and page 1 are already redirected.This adds
redirect_topic_page_trailing_slash()onbbp_template_redirect, next toredirect_page_zero_one(). On a paginated single topic it sends a 301 to theuser_trailingslashit()form of the request path, with the query string kept. POST requests are left alone./topic/<slug>/page/2: 301 to/topic/<slug>/page/2//topic/<slug>/page/2?replies=1&foo=bar: 301 to/topic/<slug>/page/2/?replies=1&foo=bar/topic/<slug>/page/2/: 200, unchangedThe
Locationheader is the request path (relative), so it stays right under the/support/site path.Testing
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.)curl -sI http://localhost:8888/topic/<slug>/page/2shows301andLocation: /topic/<slug>/page/2/.curl -sI http://localhost:8888/topic/<slug>/page/2/shows200.A Playwright run against the local environment failed on trunk with
Expected: 301 Received: 200(3 failed, 1 passed) and passes with this change (4 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