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

Fix ajax_suggest user and guest author id collision #974

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

katag9k
Copy link
Contributor

@katag9k katag9k commented Aug 2, 2023

Description

Related to #960. When a WordPress user shares the same id as a guest-author post id, the CAP meta box will display the wrong avatar after searching for user or guest author.

Steps to Test

Ensure a guest author shares the same id (post_id) with a current WordPress user id.

  • Login as the WordPress user
  • Create a new article and search for both the guest author and the WordPress user that have colliding ids in the Authors Metabox. Correct avatars will be displayed

@katag9k katag9k requested a review from GaryJones August 2, 2023 15:49
@GaryJones GaryJones added this to the 3.5.14 milestone Aug 2, 2023
Copy link
Contributor

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

I'm unable to replicate this issue, and I can't see where user_type is a recognised array key for the extra args of get_avatar_url().

@katag9k Can you shed some more light here please? Screenshots, quick video, please.

@katag9k
Copy link
Contributor Author

katag9k commented Aug 21, 2023

@GaryJones user_type distinction was added in the previous PR, it lives here:

if ( isset( $args['user_type'] ) && 'wp-user' === $args['user_type'] ) {
return $args;
}

When adding authors to a post but before saving the post, the incorrect avatar will show up for users that have the same ID as the guest author post type id.
Screenshot 2023-08-21 at 9 09 11 AM

@GaryJones
Copy link
Contributor

@katag9k I'm still not seeing it.

Screenshot 2023-08-21 at 14 24 42

In my example, "gary" is a regular user, user_id = 7. I am logged into that account. It's my face showing as it picks up the gravatar from the user email address. It happens to also exist as a mapped guest author. ✅

The "A Guest Author" account is a guest author account, not linked to a regular user. The post_id = 7. The image matches the Set Avatar feature of editing the guest profile. ✅

When I remove the guest author avatar, then it correctly falls back to the Gravatar default image:

Screenshot 2023-08-21 at 14 23 38

If I remove the guest author mapping for "gary" (so it is only a regular user), then the behaviour is the same.

I'm going to need more hand-holding to replicate this please.

@GaryJones
Copy link
Contributor

Since I was logged in as the duplicitous user, the new post I was creating already had me assigned as the author (see gary in the screenshots above).

When I added a random author (Minnie), so I could then remove gary, and then start to add gary and get the Ajax result, I could see the wrong URL being delivered.

Before - the San Francisco URL is for "A Guest Author" (post_id=7):

Screenshot 2023-08-25 at 15 54 20

After applying this PR - the Gravatar URL is the correct one for gary (user_id = 7).

Screenshot 2023-08-25 at 15 55 04

Copy link
Contributor

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

@GaryJones GaryJones merged commit 723534c into master Aug 25, 2023
10 checks passed
@GaryJones GaryJones deleted the fix-ajax-suggest-id-collision branch August 25, 2023 15:01
@GaryJones GaryJones mentioned this pull request Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants