[wp-trac] [WordPress Trac] #6953: get_post() returns bogus object for non-existing post IDs

WordPress Trac wp-trac at lists.automattic.com
Sat May 10 18:43:20 GMT 2008


#6953: get_post() returns bogus object for non-existing post IDs
---------------------+------------------------------------------------------
 Reporter:  Sam_a    |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.7      
Component:  General  |     Version:  2.5.1    
 Severity:  normal   |    Keywords:  get_post 
---------------------+------------------------------------------------------
 It should return `null` or `false` instead.

 {{{
 var_dump( get_post( $dummy_id = -999 ));
 }}}
 returns
 {{{
 object(stdClass)(1) {
   ["ancestors"]=>
   array(0) {
   }
 }
 }}}

 The object converts to boolean `true`, which can confuse things.

 `_get_post_ancestors($_post)` is being called without checking that the
 previous query actually returned a post (in
 [http://trac.wordpress.org/browser/tags/2.5.1/wp-includes/post.php#L174
 wp-includes/post.php]).

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6953>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list