Make WordPress Core


Ignore:
Timestamp:
11/10/2022 02:20:47 AM (17 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.
Merges [54771] to the 6.1 branch.
Fixes #56948.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/post.php

    r54783 r54784  
    74797479 */
    74807480function update_post_author_caches( $posts ) {
     7481    /*
     7482     * cache_users() is a pluggable function so is not available prior
     7483     * to the `plugins_loaded` hook firing. This is to ensure against
     7484     * fatal errors when the function is not available.
     7485     */
     7486    if ( ! function_exists( 'cache_users' ) ) {
     7487        return;
     7488    }
     7489
    74817490    $author_ids = wp_list_pluck( $posts, 'post_author' );
    74827491    $author_ids = array_map( 'absint', $author_ids );
Note: See TracChangeset for help on using the changeset viewer.