Skip to content

Tests: Skip local HTTP fixtures when a host declares loopback listening is restricted - #16183

Open
lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:tests/66794-loopback-fixture
Open

lancewillett wants to merge 1 commit into
WordPress:trunkfrom
lancewillett:tests/66794-loopback-fixture

Conversation

@lancewillett

@lancewillett lancewillett commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

The cURL and streams tests start a local PHP server. On hosting reporters that prohibit listening on a loopback port, the same setup failure appears 48 times. PHP can report error number zero and an empty message, so the suite cannot reliably infer the host’s policy from the error.

This lets a host set WP_TESTS_SKIP_HTTP_LOOPBACK=1 in the environment where PHPUnit runs. The setting takes effect only if PHP fails to reserve a port. The existing fixture checks then skip the cases that need the server. Other transport tests still run. A server that gets a port but never answers still fails, including with the setting enabled.

Testing

Ran the existing cURL and streams classes using PHP 8.3, PHPUnit 9.6 and random-order seed 66794. With binding denied by the macOS sandbox, trunk reported 48 failures. With this patch and the setting enabled, 48 tests skipped and the four independent cases passed on both single-site and multisite. Leaving the setting unset preserved all 48 failures.

With listening allowed, all 52 tests passed with 122 assertions both on trunk and with the patch and setting enabled. PHP syntax and PHPCS checks passed.

Separately allowed binding but blocked connections to the fixture. A redirect test for each transport still failed with the five-second readiness diagnostic. This exercises the timeout path locally. The cause of the timeouts on GoDaddy and Hostinger is still open.

Feedback from a run on a restricted hosting reporter would be welcome.

Trac ticket: https://core.trac.wordpress.org/ticket/66794

@github-actions

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

@lancewillett
lancewillett requested review from a team and a balanced review from Copilot November 23, 2026 21:29

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 the opt-in handling of loopback port reservation failures.

No open issues 🎉

What changed in this PR

Adds an opt-in setting for restricted test hosts to skip HTTP transport tests that require a local fixture server when PHP cannot reserve a loopback port.

Changes:

  • Honors WP_TESTS_SKIP_HTTP_LOOPBACK=1 only when port reservation fails.
  • Preserves normal test execution and startup failures when a port is reserved.
  • Documents the setting and its limited scope.
File Description
tests/​phpunit/​tests/​http/​base.php Sets the fixture skip reason when port reservation fails and the setting is enabled.
tests/​phpunit/​README.md Documents how restricted hosts can enable the setting.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants