[wp-trac] Re: [WordPress Trac] #8731: Taxonomies set $post_status_join = true seems unnecessarily

WordPress Trac wp-trac at lists.automattic.com
Tue May 19 00:45:47 GMT 2009


#8731: Taxonomies set $post_status_join = true seems unnecessarily
--------------------------+-------------------------------------------------
 Reporter:  bkrausz       |       Owner:  ryan     
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  2.8      
Component:  Taxonomy      |     Version:  2.7      
 Severity:  major         |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by gortsleigh):

 Replying to [comment:6 ryan]:
 > Patch excludes revisions when post_type is set to 'any'.  This will keep
 revisions from showing up where not expected.

 Ryan, this patch does not change my results, as the JOIN returns no
 results.  I updated the posts from wp-admin/edit.php just in case I was
 missing something in using wp_insert_post() -- still no results.

 The question is why the JOIN returns zero results. query.php at about line
 1956 sets $post_ids to the result of get_objects_in_term( - the posts
 returned by that function all have a post_parent of 0, which is why the
 join returns no results.

 The join looks like
 {{{
 SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts JOIN wp_posts AS p2 ON
 (wp_posts.post_parent = p2.ID) WHERE 1=1 AND wp_posts.ID IN (20, 37, 71)
 AND wp_posts.post_type != 'revision' AND ((wp_posts.post_status =
 'publish') OR (wp_posts.post_status = 'inherit' AND (p2.post_status =
 'publish'))) ORDER BY wp_posts.post_date DESC LIMIT 0, 25
 }}}


 The posts here with IDs 20,37,71 have post_parent = 0 because they are
 primary posts, ie not revisions.  It seems the join is wrong ... that the
 left-hand side should remain the wp_posts.ID, and the join should be based
 on p2.post_parent = wp_posts.ID

 Unfortunately, I'm not clear on what the result set should like like if
 there are revisions being returned, so I'm not sure that simply reversing
 the criteria is what you need.  It *does* return the correct results for
 me, however!

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


More information about the wp-trac mailing list