[wp-trac] [WordPress Trac] #56948: WP_Query::the_post causes a type warning when querying for ids, not full post objects
WordPress Trac
noreply at wordpress.org
Thu Nov 3 04:14:58 UTC 2022
#56948: WP_Query::the_post causes a type warning when querying for ids, not full
post objects
--------------------------------------+---------------------
Reporter: konyoldeath | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1.1
Component: Query | Version: 6.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+---------------------
Comment (by peterwilsoncc):
> Doesn't initializing the loop indicate that they are at minimum going to
use the posts? Since each loop will call `setup_postdata`?
I guess so, yeah, for `id=>parent` it's just not going to be the posts
they expect as `setup_postdata()` will use the parent ID.
I've pushed a few additional commits to the [https://github.com/WordPress
/wordpress-develop/pull/3553 linked pull request], in addition to the
changes above:
* account for the post array being either post objects or IDs
* run `_prime_post_caches()` with the IDs to ensure the post objects are
primed
* convert post IDs to objects
* ensure author cache warming is done with post objects
There is a risk it's doing unnecessary work, so feel free to push back if
you feel the need.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56948#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list