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
This commit is contained in:
parent
06ee370814
commit
cc2ddb8421
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue