From 3087927a5ff09a691e929c0d6553b02fa259e9c3 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 29 Aug 2023 22:13:18 +0000 Subject: [PATCH] Posts, Post Types: Avoid redundant SQL query in get_pages(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids an additional query by passing the query args directly to the `WP_Query::query()` method, rather than to the constructor and calling get_posts(), following [55569]. Props david.binda, azaozz, spacedmonkey, mukesh27, flixos90, SergeyBiryukov, joemcgill. Fixes #59224. Built from https://develop.svn.wordpress.org/trunk@56491 git-svn-id: http://core.svn.wordpress.org/trunk@56003 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 0bd4fc7a9f..f71a0a061d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -6105,8 +6105,8 @@ function get_pages( $args = array() ) { */ $query_args = apply_filters( 'get_pages_query_args', $query_args, $parsed_args ); - $query = new WP_Query( $query_args ); - $pages = $query->get_posts(); + $pages = new WP_Query(); + $pages = $pages->query( $query_args ); if ( $child_of || $hierarchical ) { $pages = get_page_children( $child_of, $pages ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 6bff5d1dde..8436ece75b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56490'; +$wp_version = '6.4-alpha-56491'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.