Make WordPress Core


Ignore:
Timestamp:
11/09/2022 12:57:02 AM (16 months ago)
Author:
peterwilsoncc
Message:

Query: Prevent ID only queries erroring when starting the loop.

Ensure only full post objects are passed to update_post_author_caches() when called within WP_Query::the_post(). This prevents an error when starting the Loop for Queries initiated with a subset of fields or IDs only.

Props konyoldeath, dd32, lozula, TimothyBlynJacobs, spacedmonkey, mxbclang, peterwilsoncc.
Fixes #56948.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r54712 r54771  
    74627462 */
    74637463function update_post_author_caches( $posts ) {
     7464    /*
     7465     * cache_users() is a pluggable function so is not available prior
     7466     * to the `plugins_loaded` hook firing. This is to ensure against
     7467     * fatal errors when the function is not available.
     7468     */
     7469    if ( ! function_exists( 'cache_users' ) ) {
     7470        return;
     7471    }
     7472
    74647473    $author_ids = wp_list_pluck( $posts, 'post_author' );
    74657474    $author_ids = array_map( 'absint', $author_ids );
Note: See TracChangeset for help on using the changeset viewer.