WordPress.org

Make WordPress Core

Ticket #6953: 6953.patch

File 6953.patch, 503 bytes (added by Sam_a, 6 years ago)

get_post() returns &$null immediately for non-existing post IDs

  • wp-includes/post.php

     
    166166                $post = (int) $post; 
    167167                if ( ! $_post = wp_cache_get($post, 'posts') ) { 
    168168                        $_post = & $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post)); 
     169                        if ( ! $_post ) 
     170                                return $null; 
    169171                        _get_post_ancestors($_post); 
    170172                        wp_cache_add($_post->ID, $_post, 'posts'); 
    171173                }