WordPress.org

Make WordPress Core

Ticket #13753: 13753-make-ref-safe.diff

File 13753-make-ref-safe.diff, 808 bytes (added by westi, 11 years ago)

Additive patch on Ryans to also make it reference safe and not stop unnecessarily

  • wp-includes/post.php

     
    369369                wp_cache_add($post->ID, $_post, 'posts');
    370370        } else {
    371371                if ( is_object($post) )
    372                         $post = $post->ID;
    373                 $post = (int) $post;
    374                 if ( ! $_post = wp_cache_get($post, 'posts') ) {
    375                         $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
     372                        $post_id = $post->ID;
     373                else
     374                        $post_id = $post;
     375
     376                $post_id = (int) $post_id;
     377                if ( ! $_post = wp_cache_get($post_id, 'posts') ) {
     378                        $_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post_id));
    376379                        if ( ! $_post )
    377380                                return $null;
    378381                        _get_post_ancestors($_post);