[wp-trac] [WordPress Trac] #12704: Multiple post_types can no longer be specified in query

WordPress Trac wp-trac at lists.automattic.com
Tue Apr 6 20:46:02 UTC 2010


#12704: Multiple post_types can no longer be specified in query
-----------------------------+----------------------------------------------
 Reporter:  mitchoyoshitaka  |       Owner:  dd32    
     Type:  defect (bug)     |      Status:  accepted
 Priority:  normal           |   Milestone:  3.0     
Component:  Query            |     Version:  3.0     
 Severity:  normal           |    Keywords:          
-----------------------------+----------------------------------------------

Comment(by ryan):

 The following get_posts() call breaks with this change:

 {{{
 get_posts(array('post_type' => 'any', 'name' => 'apple', 'numberposts' =>
 1, 'suppress_filters' => false));
 }}}

 The query produced before this change looks like this:

 {{{
  SELECT wp_trunk_posts.* FROM wp_trunk_posts WHERE 1=1 AND
 wp_trunk_posts.post_name = 'apple' AND wp_trunk_posts.post_type !=
 'revision' AND wp_trunk_posts.post_type != 'nav_menu_item' AND
 (wp_trunk_posts.post_status = 'publish') ORDER BY wp_trunk_posts.post_date
 DESC
 }}}

 After the change it looks like this:

 {{{
 SELECT wp_trunk_posts.* FROM wp_trunk_posts WHERE 1=1 AND
 wp_trunk_posts.post_type != 'revision' AND wp_trunk_posts.post_type !=
 'nav_menu_item' AND (wp_trunk_posts.post_status = 'publish') ORDER BY
 wp_trunk_posts.post_date DESC
 }}}

 Notice that post_name is not in the query.  Since this query has no limit,
 all published posts and pages are retrieved.  This can result in memory
 exhaustion and bad performance.

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


More information about the wp-trac mailing list