[wp-trac] [WordPress Trac] #54822: Incorrectly accessing posts fetched by WP_Query in query PHPUnit tests
WordPress Trac
noreply at wordpress.org
Fri Jan 14 17:51:07 UTC 2022
#54822: Incorrectly accessing posts fetched by WP_Query in query PHPUnit tests
------------------------------+-----------------------------
Reporter: david.binda | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.0
Component: Build/Test Tools | Version:
Severity: normal | Resolution: fixed
Keywords: | Focuses:
------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"52577" 52577]:
{{{
#!CommitTicketReference repository="" revision="52577"
Tests: Avoid duplicate queries in some `WP_Query` tests.
When passing args to the `WP_Query::__construct()` method, it internally
executes the `WP_Query::get_posts()` method and stores the result in the
`WP_Query::posts` property.
When calling `WP_Query::get_posts()` again, the same SQL query gets
executed, and the result is again stored in the `WP_Query::posts`
property.
Thus, the correct usage is to read the posts already stored in the
`WP_Query::posts` property.
Follow-up to [1062/tests], [1065/tests], [1066/tests], [1070/tests],
[29805], [31286], [49900], [51144].
Props david.binda.
Fixes #54822.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54822#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list