Opened 5 years ago
Closed 5 years ago
#54822 closed defect (bug) (fixed)
Incorrectly accessing posts fetched by WP_Query in query PHPUnit tests
| Reported by: | david.binda | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.0 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
Similarly to #53280, the usage of WP_Query::get_posts() method after the WP_Query object was initialised with arguments passed to it is incorrect in tests/phpunit/tests/query/invalidQueries.php and tests/phpunit/tests/query/taxQuery.php PHPUnit tests, as it triggers just one more SQL query.
For instance: https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/query/invalidQueries.php?rev=51568#L94 or https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/query/taxQuery.php?rev=52389#L1027
Instead, the posts should be read via WP_Query::posts property.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In 52577: