HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Base
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
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
- Use wp-media/phpunit v3.3.
- Run any integration test that uses
HttpRequestTraitagainst WordPress trunk (seen on 7.2-alpha-64349). - 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wp-media/phpunit
-
enhancement Made by AI
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
enhancement Made by AI
Difficulty 3/5 1-2 days Newbie friendliness 74/100
-
wpmedia-phpunit binary breaks @runInSeparateProcess testsMay be free again @remyperona claimed this 58 days ago, and no pull request is open. Openbug Made by AI
-
Improve the library to include classes that could be common to all plugins.May be free again @hellofromahmed claimed this 764 days ago, and no pull request is open. Open
-
AdminOnly causes a Notice: Undefined offset in wordpress-develop vars.May be free again @hellofromtonya claimed this 2436 days ago, and no pull request is open. Open
All issues in wp-media/phpunit
Similar issues
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
backend gamification P0
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
semanadeinformatica/website#461 ·
-
Invalid or expired state when the OAuth state is longer than 156 charactersPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day