[wp-trac] [WordPress Trac] #30354: get_posts_by_author_sql doesn't also return prefixed where is asked to

WordPress Trac noreply at wordpress.org
Thu Dec 4 14:21:12 UTC 2014


#30354: get_posts_by_author_sql doesn't also return prefixed where is asked to
--------------------------------------+------------------------------
 Reporter:  pbearne                   |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Query                     |     Version:  3.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-unit-tests has-patch  |     Focuses:  administration
--------------------------------------+------------------------------

Comment (by pbearne):

 Good spot

 The patch adds the missing " post_type = 'post' AND " to the returned SQL

 so if you are happy I will create a new patch to remove it from the call
 in

         foreach ( (array) $wpdb->get_results( "SELECT DISTINCT
 post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post'
 AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as
 $row ) {


 Currently its add and extra post_type = 'post' AND  not good SQL but not
 broken


 Thnaks

 Paul

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30354#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list