Make WordPress Core


Ignore:
Timestamp:
06/14/2022 12:40:29 PM (4 years ago)
Author:
spacedmonkey
Message:

REST API: Avoid duplicated query in post collections.

Avoid duplicated query when retrieving empty posts collections by adding a check if the page is more than 1.

Props furi3r, gdetassigny, TimothyBlynJacobs, spacedmonkey.
Fixes #55677.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r53482 r53498  
    389389                $total_posts = $posts_query->found_posts;
    390390
    391                 if ( $total_posts < 1 ) {
     391                if ( $total_posts < 1 && $page > 1 ) {
    392392                        // Out-of-bounds, run the query again without LIMIT for total count.
    393393                        unset( $query_args['paged'] );
Note: See TracChangeset for help on using the changeset viewer.