mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 13:37:51 +01:00
Posts, Post Types: Set post filter in update_post_cache()
.
Ensure the post cache is primed with raw sanitized data. This resolves an inconsistency between how posts retrieved via `get_post()` vs `WP_Query` are cached. This prevents `sanitize_post( $post, 'raw' )` being run multiple times on a cached post. This can happen over 20 times per post on some page loads so avoiding this will provide a noticeable performance boost. Props Cybr, SergeyBiryukov, peterwilsoncc, hellofromTonya, costdev. Fixes #50567. Built from https://develop.svn.wordpress.org/trunk@53042 git-svn-id: http://core.svn.wordpress.org/trunk@52631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9131d74641
commit
dc07d3ca67
@ -247,7 +247,7 @@ final class WP_Post {
|
||||
|
||||
$_post = sanitize_post( $_post, 'raw' );
|
||||
wp_cache_add( $_post->ID, $_post, 'posts' );
|
||||
} elseif ( empty( $_post->filter ) ) {
|
||||
} elseif ( empty( $_post->filter ) || 'raw' !== $_post->filter ) {
|
||||
$_post = sanitize_post( $_post, 'raw' );
|
||||
}
|
||||
|
||||
|
@ -7374,6 +7374,9 @@ function update_post_cache( &$posts ) {
|
||||
|
||||
$data = array();
|
||||
foreach ( $posts as $post ) {
|
||||
if ( empty( $post->filter ) || 'raw' !== $post->filter ) {
|
||||
$post = sanitize_post( $post, 'raw' );
|
||||
}
|
||||
$data[ $post->ID ] = $post;
|
||||
}
|
||||
wp_cache_add_multiple( $data, 'posts' );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-alpha-53041';
|
||||
$wp_version = '6.0-alpha-53042';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user