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
This commit is contained in:
Ryan Boren 2012-11-17 15:14:48 +00:00
parent 6d8bce688f
commit 35576683fe
1 changed files with 6 additions and 2 deletions

View File

@ -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 );