From 9c0dc03f9073a0f99a73d7c9b67ea3b7a94ca8a2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 25 May 2021 23:41:57 +0000 Subject: [PATCH] Posts, Post Types: Speed cached `get_pages()` calls. This improves performance for sites with persistent cache backend having a lot of pages requested via the `get_pages() function, by taking advantage of `wp_cache_get_multiple()` instead of fetching each individual page from the backend cache server one by one. It also matches the behaviour of `get_pages()` when the pages are retrieved from the database. Props david.binda, hellofromTonya. Fixes #51469. Built from https://develop.svn.wordpress.org/trunk@51018 git-svn-id: http://core.svn.wordpress.org/trunk@50627 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index df0ca10695..e7fae22267 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -5784,10 +5784,13 @@ function get_pages( $args = array() ) { $cache_key = "get_pages:$key:$last_changed"; $cache = wp_cache_get( $cache_key, 'posts' ); if ( false !== $cache ) { + _prime_post_caches( $cache, false, false ); + // Convert to WP_Post instances. $pages = array_map( 'get_post', $cache ); /** This filter is documented in wp-includes/post.php */ $pages = apply_filters( 'get_pages', $pages, $parsed_args ); + return $pages; } @@ -5948,6 +5951,7 @@ function get_pages( $args = array() ) { /** This filter is documented in wp-includes/post.php */ $pages = apply_filters( 'get_pages', array(), $parsed_args ); + return $pages; } @@ -7605,7 +7609,7 @@ function _update_term_count_on_transition_post_status( $new_status, $old_status, } /** - * Adds any posts from the given IDs to the cache that do not already exist in cache + * Adds any posts from the given IDs to the cache that do not already exist in cache. * * @since 3.4.0 * @access private diff --git a/wp-includes/version.php b/wp-includes/version.php index 49154780e7..a12fd358ff 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51017'; +$wp_version = '5.8-alpha-51018'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.