Repository navigation
Conversation
`_oembed_rest_pre_serve_request()` sends a 501 status and calls `die()` when the `SimpleXMLElement` class does not exist. Two tests call it for an XML response without checking for the extension, so on a PHP build without SimpleXML the whole PHPUnit run stops there, printing "Not Implemented" and exiting with a zero status. These tests now require the `simplexml` extension and are skipped without it.
|
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:
|
With the two response tests guarded, six more tests fail on a build without SimpleXML: `test_oembed_create_xml` uses the extension directly, and five discovery link tests expect the XML link, which is only output when the `SimpleXMLElement` class exists. The ticket annotation added to existing tests in the previous commit is removed; only the extension requirement is added.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for this test-only change adding SimpleXML requirements to XML-dependent oEmbed tests.
No open issues 🎉
What changed in this PR
This test-only change makes the oEmbed suite skip tests that depend on SimpleXML when the extension is unavailable, preventing premature PHPUnit termination and XML-related assertion failures.
Changes:
- Adds
@requires extension simplexmlto two XML response tests and the XML creation test. - Adds the same requirement to five discovery-link tests that expect XML output.
- Leaves production code unchanged.
| File | Description |
|---|---|
tests/phpunit/tests/oembed/headers.php |
Requires SimpleXML for the XML response header test. |
tests/phpunit/tests/oembed/discovery.php |
Requires SimpleXML for five tests expecting XML discovery links. |
tests/phpunit/tests/oembed/controller.php |
Requires SimpleXML for XML creation and REST response tests. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
I reproduced the silent stop on PHP 8.3 without SimpleXML. The XML controller and header tests do need the extension.
Could you keep the five discovery tests running and make only the expected XML link conditional? WordPress still emits the JSON link and runs the discovery filter without SimpleXML. Skipping the methods also drops the check that the two wp_head priorities emit the links only once.
I tried that change locally. Without SimpleXML, the same 140-test run went from 386 assertions and eight skips to 408 assertions and three skips. With SimpleXML it still ran 413 assertions with one skip.
AI review · gpt-6
Instead of skipping the five discovery tests when SimpleXML is unavailable, only expect the XML discovery link when `SimpleXMLElement` exists, matching the condition in `wp_oembed_add_discovery_links()`. The JSON link, the `oembed_discovery_links` filter and the back-compat check for the two `wp_head` priorities are then still covered without the extension. Follow-up to review feedback from lancewillett. See #66788.
|
Thanks for reproducing it, and you're right. Skipping the five discovery tests also dropped the JSON link, the filter and the I've pushed 14ff0ec and 5e26f00. The discovery tests now run everywhere and only expect the XML link when With |
lancewillett
left a comment
There was a problem hiding this comment.
Thanks for keeping the discovery tests running. I verified the revised oEmbed suite with and without SimpleXML on single-site and multisite. I found one remaining issue when running the headers test with Xdebug enabled. Moving one annotation fixes it locally.
AI review · gpt-6
The test runs in a separate process. With Xdebug enabled and SimpleXML missing, PHPUnit reports an error while reading the skipped result from the child process. A class-level requirement skips before the child process starts. Props lancewillett. See #66788.
|
Thanks Lance, that makes sense. I've moved To be clear about what I've checked: I don't have Xdebug in either of my test environments, so I haven't reproduced the As before, I used an AI assistant (Claude) to help prepare this change, and I've read the diff myself. |
lancewillett
left a comment
There was a problem hiding this comment.
Thanks, Shane. I reproduced the previous header-test error with PHPUnit 9.6.39 and Xdebug 3.2.0 in develop mode. On 71b4304, the class-level requirement skips the test cleanly without SimpleXML. With SimpleXML enabled, both header assertions pass.
The randomized oEmbed runs also completed on single-site and multisite with the extension enabled and disabled. The five discovery tests retain their JSON coverage. Ready for trunk.
AI review · gpt-6
Require `SimpleXML` for the XML-only tests so an unavailable extension cannot end the PHPUnit run early with a successful exit code. Check the requirement before starting the isolated headers test. Keep checking JSON discovery links and filters on every build. Expect the XML discovery link only when `SimpleXMLElement` is available. Developed in: #16171 Props shanerounce. Fixes #66788. git-svn-id: https://develop.svn.wordpress.org/trunk@65754 602fd350-edb4-49c9-b593-d223f7449a82
Require `SimpleXML` for the XML-only tests so an unavailable extension cannot end the PHPUnit run early with a successful exit code. Check the requirement before starting the isolated headers test. Keep checking JSON discovery links and filters on every build. Expect the XML discovery link only when `SimpleXMLElement` is available. Developed in: WordPress/wordpress-develop#16171 Props shanerounce. Fixes #66788. Built from https://develop.svn.wordpress.org/trunk@65754 git-svn-id: http://core.svn.wordpress.org/trunk@64784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
_oembed_rest_pre_serve_request()sends a 501 status and callsdie()when theSimpleXMLElementclass does not exist.Tests_oEmbed_Controller::test_rest_pre_serve_requestandTests_oEmbed_HTTP_Headers::test_rest_pre_serve_request_headerscall it for an XML response without requiring the extension.On a PHP build without SimpleXML the
die()ends the whole PHPUnit process. It prints "Not Implemented" and exits with status 0, so the remaining tests never run and no summary is printed.This adds
@requires extension simplexmlto those two tests so they are skipped when the extension is missing. Once the run gets past them, six more oEmbed tests fail on such a build.test_oembed_create_xmluses the extension directly, so it gets the same requirement. Five discovery link tests expect the XML link, which is only output whenSimpleXMLElementexists. Those five keep running and now only expect the XML link under that same condition, so the JSON link, theoembed_discovery_linksfilter and thewp_headpriority check are still covered without the extension (changed after review feedback from @lancewillett).It is a test-only change.
Testing
On PHP builds without SimpleXML (8.5.12 and 8.6.0):
tests/oembed/controller.php, PHP 8.6.0test_rest_pre_serve_requestwith "Not Implemented", exit status 0, no summarytests/oembed/controller.php--group oembedWith SimpleXML present (PHP 8.4.25, 8.5.12 and 8.6.0),
--group oembedpasses with nothing newly skipped (142 tests, 417 assertions, 1 skip). PHPCS passes on the changed files.In the default suite on trunk with PHP 8.6.0, the stop happened at the 19,424th test.
Trac ticket: https://core.trac.wordpress.org/ticket/66788
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: Tracing the stopped test run to its cause, writing the change and this description, and running the tests. The test results above are automated runs by the tool.