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:
@@ -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' );
|
||||
|
||||
Reference in New Issue
Block a user