Skip to content

Tests: Skip oEmbed XML response tests when SimpleXML is not available - #16171

Closed
AceMedia wants to merge 6 commits into
WordPress:trunkfrom
AceMedia:ticket/oembed-simplexml-test-guard
Closed

AceMedia wants to merge 6 commits into
WordPress:trunkfrom
AceMedia:ticket/oembed-simplexml-test-guard

Conversation

@AceMedia

@AceMedia AceMedia commented Nov 23, 2026 •

Copy link
Copy Markdown

_oembed_rest_pre_serve_request() sends a 501 status and calls die() when the SimpleXMLElement class does not exist. Tests_oEmbed_Controller::test_rest_pre_serve_request and Tests_oEmbed_HTTP_Headers::test_rest_pre_serve_request_headers call 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 simplexml to 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_xml uses the extension directly, so it gets the same requirement. Five discovery link tests expect the XML link, which is only output when SimpleXMLElement exists. Those five keep running and now only expect the XML link under that same condition, so the JSON link, the oembed_discovery_links filter and the wp_head priority 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):

Result
trunk, tests/oembed/controller.php, PHP 8.6.0 The process ends at test_rest_pre_serve_request with "Not Implemented", exit status 0, no summary
This change, tests/oembed/controller.php Passes on both versions (27 tests, 172 assertions, 2 skips)
This change, --group oembed Passes on both versions (142 tests, 412 assertions, 3 skips). Before the review change it was 390 assertions and 8 skips.

With SimpleXML present (PHP 8.4.25, 8.5.12 and 8.6.0), --group oembed passes 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.

`_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.
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

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:

Props shanerounce, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 simplexml to 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 lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@AceMedia

Copy link
Copy Markdown
Author

Thanks for reproducing it, and you're right. Skipping the five discovery tests also dropped the JSON link, the filter and the wp_head priority checks, none of which need SimpleXML.

I've pushed 14ff0ec and 5e26f00. The discovery tests now run everywhere and only expect the XML link when SimpleXMLElement exists, which is the same condition wp_oembed_add_discovery_links() uses. The controller and header tests keep their @requires.

With --group oembed (142 tests) on PHP 8.5.12 and 8.6.0 without SimpleXML, the run went from 390 assertions and eight skips to 412 assertions and three skips. With SimpleXML it is unchanged at 417 assertions and one skip. Those are automated runs by Claude Code, which also wrote the change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for this test-only SimpleXML compatibility change.

No open issues 🎉

Review effort: Balanced

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tests/phpunit/tests/oembed/headers.php Resolved
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.
@AceMedia

Copy link
Copy Markdown
Author

Thanks Lance, that makes sense. I've moved @requires extension simplexml to the class docblock in tests/phpunit/tests/oembed/headers.php, so the class is skipped before the child process starts.

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 SyntheticSkippedError::$xdebug_message error myself and I'm relying on your result for that case. Locally the file passes PHPCS and the test is skipped as expected without Xdebug. CI should cover the Xdebug run with SimpleXML enabled.

As before, I used an AI assistant (Claude) to help prepare this change, and I've read the diff myself.

@lancewillett lancewillett left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the test-only changes to SimpleXML-dependent oEmbed coverage.

No open issues 🎉

Review effort: Balanced

wporg-sync pushed a commit that referenced this pull request Nov 24, 2026
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
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 65754
GitHub commit: d0ba880

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Nov 24, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 24, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants