[wp-trac] [WordPress Trac] #45105: wp_list_authors() performance issue. Queries for user data on authors with no posts
WordPress Trac
noreply at wordpress.org
Wed Apr 10 20:24:41 UTC 2019
#45105: wp_list_authors() performance issue. Queries for user data on authors with
no posts
-------------------------------------+--------------------------
Reporter: billerickson | Owner: ianbelanger
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 5.2
Component: Users | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: performance
-------------------------------------+--------------------------
Changes (by ianbelanger):
* keywords: has-patch => has-patch needs-testing
Comment:
I tested the patch and it does limit the number queries as intended,
however it was throwing 2 PHP notices for each user due to the fact that
`$author = get_userdata( $author_id );` was moved after `$posts = isset(
$author_count[ $author->ID ] ) ? $author_count[ $author->ID ] : 0;` in the
loop, so `$author` was not yet defined.
45105.1.diff changes `$posts = isset( $author_count[ $author->ID ] ) ?
$author_count[ $author->ID ] : 0;` to `$posts = isset( $author_count[
$author_id ] ) ? $author_count[ $author_id ] : 0;` to avoid throwing the
PHP notices, while still limiting the number of queries.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45105#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list