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. Built from https://develop.svn.wordpress.org/trunk@53498 git-svn-id: http://core.svn.wordpress.org/trunk@53087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c7ab92451a
commit
7df9ba26b2
|
@ -388,7 +388,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||||
$page = (int) $query_args['paged'];
|
$page = (int) $query_args['paged'];
|
||||||
$total_posts = $posts_query->found_posts;
|
$total_posts = $posts_query->found_posts;
|
||||||
|
|
||||||
if ( $total_posts < 1 ) {
|
if ( $total_posts < 1 && $page > 1 ) {
|
||||||
// Out-of-bounds, run the query again without LIMIT for total count.
|
// Out-of-bounds, run the query again without LIMIT for total count.
|
||||||
unset( $query_args['paged'] );
|
unset( $query_args['paged'] );
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53497';
|
$wp_version = '6.1-alpha-53498';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue