From cc2ddb84214948c2edea1713e28323dcae820cc4 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: http://core.svn.wordpress.org/trunk@22635 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 );