mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@53498 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -388,7 +388,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
$page = (int) $query_args['paged'];
|
||||
$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.
|
||||
unset( $query_args['paged'] );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user