mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 21:30:26 +00: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. git-svn-id: https://develop.svn.wordpress.org/trunk@53042 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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' );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user