Repository navigation
Conversation
|
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:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the oEmbed route-matching change.
No open issues 🎉
What changed in this PR
Fixes oEmbed XML responses for differently cased REST routes by aligning the response handler’s route matching with the REST server.
Changes:
- Replaces the exact route comparison with a case-insensitive regular expression.
- Adds regression tests for lowercase, mixed-case, uppercase, and trailing-newline routes, plus a check that unrelated routes remain unaffected.
| File | Description |
|---|---|
tests/phpunit/tests/oembed/controller.php |
Adds XML-response and unrelated-route regression tests. |
src/wp-includes/embed.php |
Aligns oEmbed route matching with REST server behavior. |
Review effort: Balanced
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Thanks @westonruter, For the review. I have addressed the feedbacks. |
Trac ticket: https://core.trac.wordpress.org/ticket/66723
_oembed_rest_pre_serve_request()compared the request route to/oembed/1.0/embedas an exact string, butWP_REST_Servermatches routes case-insensitively ('@^' . $route . '$@i'). A request to/wp-json/oEmbed/1.0/embed?format=xmlis still dispatched to the oEmbed controller, but it fails the exact-string check, soformat=xmlis ignored and the response is sent as JSON.This PR matches the route with the REST server's own pattern, the same approach r64432 took for
_wp_connectors_rest_settings_dispatch()in #66330.Changes
src/wp-includes/embed.php: match the route withpreg_match( '@^/oembed/1.0/embed$@i', ... )instead of!==.tests/phpunit/tests/oembed/controller.php:test_rest_pre_serve_request_serves_xml_for_every_route_spelling()dispatches each spelling of the route (lowercase, mixed case, uppercase, trailing newline), asserts the oEmbed controller handled it, and asserts the callback prints XML.test_rest_pre_serve_request_ignores_other_routes()asserts that another route (/oEmbed/1.0/proxy) withformat=xmlis left for the REST server and prints nothing.Testing instructions
/?rest_route=/oEmbed/1.0/embed&url=<post-url>&format=xmlinstead.Content-Type: text/xmland the second returns JSON. With this PR, both return XML.Automated tests:
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafting the fix, the tests and this description. I reviewed the changes and ran the tests myself.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.