Repository navigation
Conversation
Adds regression tests for `redirect_canonical()` where a term slug is named like a feed endpoint (`feed`, `rss`, `rss2`, `rdf`, `atom`). They cover tags, categories and a custom taxonomy with a real trailing feed segment (`/feed/`, `/feed/atom/`, `/feed/rdf/`, `/feed/rss/`, `/feed/rss2/` and the `/atom/` and `/rss2/` shorthand), and single posts in a category with such a slug combined with `/comment-page-2/` and comment feeds. Props irozum. See https://core.trac.wordpress.org/ticket/21700.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: https://core.trac.wordpress.org/ticket/21700
This adds extra regression tests on top of irozum's PR, WordPress#14305. It is a tests-only commit on their exact head (bfcddbc) and does not touch
src/. Props irozum.What the tests cover
All additions are in
tests/phpunit/tests/canonical.php, tagged@ticket 21700.feed,rss,rss2,rdfandatom, requested with a real trailing feed segment:/feed/,/feed/atom/,/feed/rdf/,/feed/rss/and/feed/rss2/. The slug must be kept and the real feed segment resolved to the expected canonical feed URL. The/atom/and/rss2/shorthand is covered too, except for the slugfeed, where/tag/feed/atom/is ambiguous./%category%/%postname%/) combined with/comment-page-2/,/feed/and/feed/atom/. Post slugs themselves cannot match a feed endpoint, becausewp_unique_post_slug()renames them, so the feed-like segment is the category.That is 99 term cases and 15 post cases (114 new cases). All 114, plus the PR's own 5 feed cases, fail on trunk (PR source change reverted temporarily) and pass on the PR head. I removed cases that passed either way and did not enter the changed loop (plain archive URLs,
?cpage=and?feed=on posts).What the tests do not cover
Extra cases I tried fail on the PR head as well as on trunk, so I left them out of the commit: a term slug with a real second page (
/tag/rss/page/2/,?paged=2) and a term slug with?feed=atomor?feed=rss2, where the slug is still stripped (for example/tag/rss/page/2/becomes/tag/page/2/). The PR's own paged cases pass only because page 2 does not exist with one post. I can share those cases if useful, but I have not changed the PR's production code.Testing and limits
tests/phpunit/tests/canonical.php: 212 tests, 238 assertions, passing in single site and multisite configurations.php -lare clean on the changed file.src/wp-includes/canonical.phpchange, restored afterwards.AI assistance: Codex and Claude helped me assess the issue, write the tests and run the checks. I have reviewed the code myself. The test results are from automated runs through my local test setup.