| 1 | Index: wp-includes/post.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/post.php (revision 22261) |
|---|
| 4 | +++ wp-includes/post.php (working copy) |
|---|
| 5 | @@ -388,8 +388,14 @@ |
|---|
| 6 | $_post = $post; |
|---|
| 7 | } elseif ( is_object( $post ) ) { |
|---|
| 8 | if ( empty( $post->filter ) ) { |
|---|
| 9 | - $_post = sanitize_post( $post, 'raw' ); |
|---|
| 10 | - wp_cache_add( $post->ID, $_post, 'posts' ); |
|---|
| 11 | + $core_props = WP_Post::get_core_property_list(); |
|---|
| 12 | + $props = array_keys( get_object_vars( $post ) ); |
|---|
| 13 | + if ( ( count( $core_props ) == count ( $props ) ) && ( ! array_diff( $core_props, $props ) ) ) { |
|---|
| 14 | + $_post = sanitize_post( $post, 'raw' ); |
|---|
| 15 | + wp_cache_add( $post->ID, $_post, 'posts' ); |
|---|
| 16 | + } else { |
|---|
| 17 | + $_post = sanitize_post( $post, 'raw' ); |
|---|
| 18 | + } |
|---|
| 19 | $_post = new WP_Post( $_post ); |
|---|
| 20 | } elseif ( 'raw' == $post->filter ) { |
|---|
| 21 | $_post = new WP_Post( $post ); |
|---|
| 22 | @@ -542,6 +548,34 @@ |
|---|
| 23 | |
|---|
| 24 | return $post; |
|---|
| 25 | } |
|---|
| 26 | + |
|---|
| 27 | + public static function get_core_property_list() { |
|---|
| 28 | + return array ( |
|---|
| 29 | + 'ID', |
|---|
| 30 | + 'post_author', |
|---|
| 31 | + 'post_date', |
|---|
| 32 | + 'post_date_gmt', |
|---|
| 33 | + 'post_content', |
|---|
| 34 | + 'post_title', |
|---|
| 35 | + 'post_excerpt', |
|---|
| 36 | + 'post_status', |
|---|
| 37 | + 'comment_status', |
|---|
| 38 | + 'ping_status', |
|---|
| 39 | + 'post_password', |
|---|
| 40 | + 'post_name', |
|---|
| 41 | + 'to_ping', |
|---|
| 42 | + 'pinged', |
|---|
| 43 | + 'post_modified', |
|---|
| 44 | + 'post_modified_gmt', |
|---|
| 45 | + 'post_content_filtered', |
|---|
| 46 | + 'post_parent', |
|---|
| 47 | + 'guid', |
|---|
| 48 | + 'menu_order', |
|---|
| 49 | + 'post_type', |
|---|
| 50 | + 'post_mime_type', |
|---|
| 51 | + 'comment_count', |
|---|
| 52 | + ); |
|---|
| 53 | + } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|