Make WordPress Core


Ignore:
Timestamp:
06/10/2022 01:37:52 PM (2 years ago)
Author:
spacedmonkey
Message:

Prime users cache in WP_Query and post REST API controller.

For a call to WP_Query or a post REST API request that contains posts from multiple authors, call the cache_users function, to ensure that all user data for post authors is primed in
a single database query. This results in far fewer database queries on multiple author sites.

Props spacedmonkey, timothyblynjacobs, peterwilsoncc.
Fixes #55716.

File:
1 edited

Legend:

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

    r53469 r53482  
    34353435    public function the_post() {
    34363436        global $post;
     3437        if ( ! $this->in_the_loop ) {
     3438            update_post_author_caches( $this->posts );
     3439        }
    34373440        $this->in_the_loop = true;
    34383441
Note: See TracChangeset for help on using the changeset viewer.