[wp-trac] [WordPress Trac] #10803: get_post_meta doesn't return an array when requested if nothing with that key exists.

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 25 08:01:54 UTC 2009


#10803: get_post_meta doesn't return an array when requested if nothing with that
key exists.
--------------------------+-------------------------------------------------
 Reporter:  westi         |        Owner:  westi   
     Type:  defect (bug)  |       Status:  reopened
 Priority:  normal        |    Milestone:  2.9     
Component:  General       |      Version:  2.8.4   
 Severity:  normal        |   Resolution:          
 Keywords:  2nd-opinion   |  
--------------------------+-------------------------------------------------
Changes (by Denis-de-Bernardy):

  * status:  closed => reopened
  * resolution:  fixed =>


Comment:

 I might be understanding this patch incorrectly, but it seems to me that
 this fix prevents it from distinguishing between a post meta that does not
 exist and one that has yet to be generated.

 until 2.8, it's possible to do:

 {{{
 $children = get_post_meta($post_id, _children_cache);
 if ( $children === '' )
   $children = cache_children($post_id); // might now contain array()
 foreach ( $children as $child ) ...
 }}}

 if get_post_meta() returns an empty array instead, the above code no
 longer works.

 since we're going to break things as a result, could we not make the mess
 return false instead?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10803#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list