REST API: Prime caches for featured images in post controller.

Ensure that featured image caches are primed for post collections in the post REST API controller, by calling the `update_post_thumbnail_cache` function. 

Props Spacedmonkey, TimothyBlynJacobs, mitogh.
Fixes #55592. 


Built from https://develop.svn.wordpress.org/trunk@53499


git-svn-id: http://core.svn.wordpress.org/trunk@53088 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey 2022-06-14 13:10:10 +00:00
parent 7df9ba26b2
commit 77f62c11db
2 changed files with 4 additions and 1 deletions

View File

@ -370,6 +370,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
$posts = array();
update_post_author_caches( $query_result );
if ( post_type_supports( $this->post_type, 'thumbnail' ) ) {
update_post_thumbnail_cache( $posts_query );
}
foreach ( $query_result as $post ) {
if ( ! $this->check_read_permission( $post ) ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53498';
$wp_version = '6.1-alpha-53499';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.