Make WordPress Core

Changeset 51018


Ignore:
Timestamp:
05/25/2021 11:40:12 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r51015 r51018  
    57855785        $cache     = wp_cache_get( $cache_key, 'posts' );
    57865786        if ( false !== $cache ) {
     5787                _prime_post_caches( $cache, false, false );
     5788
    57875789                // Convert to WP_Post instances.
    57885790                $pages = array_map( 'get_post', $cache );
    57895791                /** This filter is documented in wp-includes/post.php */
    57905792                $pages = apply_filters( 'get_pages', $pages, $parsed_args );
     5793
    57915794                return $pages;
    57925795        }
     
    59495952                /** This filter is documented in wp-includes/post.php */
    59505953                $pages = apply_filters( 'get_pages', array(), $parsed_args );
     5954
    59515955                return $pages;
    59525956        }
     
    76067610
    76077611/**
    7608  * Adds any posts from the given IDs to the cache that do not already exist in cache
     7612 * Adds any posts from the given IDs to the cache that do not already exist in cache.
    76097613 *
    76107614 * @since 3.4.0
Note: See TracChangeset for help on using the changeset viewer.