[wp-trac] [WordPress Trac] #33068: get_post() returning current object if 0

WordPress Trac noreply at wordpress.org
Wed Jul 22 11:02:18 UTC 2015


#33068: get_post() returning current object if 0
-------------------------------+-----------------------------
 Reporter:  Rahe               |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.2.2
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 When calling get_post(0) and the global object post is set, the current
 object is returned.
 Like in this example :

 {{{
 global $post;
 $post = get_post(384);
 var_dump( get_post(0));
 }}}

 The get_post returns the 384 object, and not null as expected when needing
 the object 0, that doesn't exists.
 I propose this patch for stricly checking this is not 0 for this case and
 not just the handy empty.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33068>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list