Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Base

Open Beginner friendly
#62 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
testing

Research direction

Start with the $blocked_http_requests property and its uses in src/Integration/HttpRequestTrait.php, then compare it with the protected declaration in WordPress's tests/phpunit/includes/abstract-testcase.php. The five-line snippet in the issue reproduces the clash without WordPress. Done means an integration test that uses the trait loads on WordPress trunk and the package's own tests still pass.

Written by the indexing model from the issue text.

Description

Describe the bug
On WordPress trunk (7.2-alpha), any integration test class that uses HttpRequestTrait fails to load:

PHP Fatal error: WP_UnitTestCase_Base and WPMedia\PHPUnit\Integration\HttpRequestTrait define the same property ($blocked_http_requests) in the composition of … However, the definition differs and is considered incompatible.

Core added its own external-HTTP blocking to the base test case (@since 7.2.0) and used the same property name:

  • WordPress, tests/phpunit/includes/abstract-testcase.php: protected array $blocked_http_requests = array();
  • this package, src/Integration/HttpRequestTrait.php: private $blocked_http_requests = [];

PHP won't compose a trait property that differs from an inherited one.

To Reproduce

  1. Use wp-media/phpunit v3.3.
  2. Run any integration test that uses HttpRequestTrait against WordPress trunk (seen on 7.2-alpha-64349).
  3. See the fatal error above.

The same error without WordPress, in five lines:

abstract class Base { protected array $blocked_http_requests = array(); }
trait T { private $blocked_http_requests = []; }
class Test extends Base { use T; }
Dominant language
PHP
Stars
4
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-media/phpunit

All issues in wp-media/phpunit

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.