Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

column_posts() should use user_login when querying for linked_account #558

Merged
merged 1 commit into from
Jul 10, 2018
Merged

column_posts() should use user_login when querying for linked_account #558

merged 1 commit into from
Jul 10, 2018

Conversation

TheCrowned
Copy link
Contributor

This fixes #554.

In the Guest Authors view, some authors would have a wrong post count. This would happen for users with a user_login different than the user_nicename.

Up to now, due to this Core issue, count_user_posts() would return the total site posts count for those users. When that bug will be fixed, it will return 0. In any case, it is not the correct count.

The issue lies in this part of the code:

if ( ! empty( $item->linked_account ) && $guest_term->count ) {
	$count = count_user_posts( get_user_by( 'slug', $item->linked_account )->ID );

because $item->linked_account contains the user login rather than the slug (which would be the nicename). Besides returning a wrong count, it would also generate a bunch of PHP Notices because get_user_by would return false and we would thus be fetching property of non-object.

screenshot from 2018-07-04 11-10-27

@mdbitz
Copy link
Contributor

mdbitz commented Jul 10, 2018

This looks good to me I'm seeing counts returned based on the login and no notices in my test install.

Copy link
Contributor

@mdbitz mdbitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, note unit test is pre-existing failure.

@mdbitz mdbitz merged commit 1bb6378 into Automattic:master Jul 10, 2018
rebeccahum pushed a commit that referenced this pull request Mar 26, 2019
…ount

column_posts() should use user_login when querying for linked_account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

get_user_by should use user_login when querying linked_account
2 participants