Make WordPress Core


Ignore:
Timestamp:
03/07/2015 01:14:31 AM (10 years ago)
Author:
boonebgorges
Message:

When passing $full to get_posts_by_author_sql(), make sure a 'post_type' clause is included in results.

This change makes the 'post_type' clause in wp_list_authors() redundant, so
we remove it. Third-party plugins using get_posts_by_author_sql() may have
similarly redundant clauses, but this won't change the results returned by the
SQL queries.

Also adds unit tests for get_posts_by_author_sql().

Props pbearne.
Fixes #30354.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/author-template.php

    r31168 r31653  
    338338
    339339    $author_count = array();
    340     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 ) {
     340    foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) {
    341341        $author_count[$row->post_author] = $row->count;
    342342    }
Note: See TracChangeset for help on using the changeset viewer.