[wp-trac] [WordPress Trac] #8348: get_posts behaviour altered

WordPress Trac wp-trac at lists.automattic.com
Wed Nov 26 00:13:45 GMT 2008


#8348: get_posts behaviour altered
---------------------+------------------------------------------------------
 Reporter:  hailin   |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.7      
Component:  General  |     Version:           
 Severity:  normal   |    Keywords:           
---------------------+------------------------------------------------------
 After recent changes in get_posts, probably related to: #7326, get_posts
 returned false whereas previously returned a valid value.

 The specific call is from a wpmu plugin:

 if ( !$posts =& get_posts( array('meta_key' => '_vidavee', 'meta_value' =>
 $asset_id, 'post_type' => 'attachment', 'post_status' => 'inherit') ) )
                 return false;

 Given the same parameters, the call used to return a valid attachment
 post. Now it returns false.

 The root cause is in function get_posts($args = null)  in wp-
 includes/post.php.
 When I comment out 'post_parent' => 0 in $defaults array, the above
 get_posts call will continue to return valid result.

 Not sure why we added 'post_parent' => 0 in the first place. Also not sure
 if we remove 'post_parent' => 0, whether it will cause other side effects.

 One walk-around is to add post_parent='post' to the wpmu get_posts call,
 but it's kind of weird that we had to do that. And if we don't address
 this in the core, ALL
 other similar calls need to be amended similarly.

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


More information about the wp-trac mailing list