WordPress.org

Make WordPress Core

Changeset 22635


Ignore:
Timestamp:
11/17/2012 03:14:48 PM (6 years ago)
Author:
ryan
Message:

Always return a raw filtered post object from WP_Post::get_instance().

Props kovshenin, scribu, ntm
fixes #22448

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r22464 r22635  
    569569
    570570        $post_id = (int) $post_id;
    571         if ( !$post_id )
     571        if ( ! $post_id )
    572572            return false;
    573573
    574         if ( ! $_post = wp_cache_get( $post_id, 'posts' ) ) {
     574        $_post = wp_cache_get( $post_id, 'posts' );
     575
     576        if ( ! $_post ) {
    575577            $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id ) );
    576578
     
    580582            $_post = sanitize_post( $_post, 'raw' );
    581583            wp_cache_add( $_post->ID, $_post, 'posts' );
     584        } elseif ( empty( $_post->filter ) ) {
     585            $_post = sanitize_post( $_post, 'raw' );
    582586        }
    583587
Note: See TracChangeset for help on using the changeset viewer.