From 35576683fe1422967580a6c26e659f5a4b6e0cb9 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 17 Nov 2012 15:14:48 +0000 Subject: [PATCH] Always return a raw filtered post object from WP_Post::get_instance(). Props kovshenin, scribu, ntm fixes #22448 git-svn-id: https://develop.svn.wordpress.org/trunk@22635 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index eecdd7bf91..b4166ea0e2 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -568,10 +568,12 @@ final class WP_Post { global $wpdb; $post_id = (int) $post_id; - if ( !$post_id ) + if ( ! $post_id ) return false; - if ( ! $_post = wp_cache_get( $post_id, 'posts' ) ) { + $_post = wp_cache_get( $post_id, 'posts' ); + + if ( ! $_post ) { $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) ); if ( ! $_post ) @@ -579,6 +581,8 @@ final class WP_Post { $_post = sanitize_post( $_post, 'raw' ); wp_cache_add( $_post->ID, $_post, 'posts' ); + } elseif ( empty( $_post->filter ) ) { + $_post = sanitize_post( $_post, 'raw' ); } return new WP_Post( $_post );