Skip to content

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
@GaryJones GaryJones added the type: bug Something isn't working label 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.

@GaryJones GaryJones added the status: awaiting reporter feedback Awaiting feedback from reporter label Aug 19, 2023
@GaryJones GaryJones removed this from the 3.5.14 milestone Aug 20, 2023
@katag9k
Copy link
Contributor Author

katag9k commented Aug 21, 2023

@GaryJones user_type distinction was added in the previous PR, it lives here: https://github.com/Automattic/Co-Authors-Plus/blob/45dbb837a8803b524fdbc207fb2538790aabae7c/co-authors-plus.php#L1858-L1860

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 GaryJones added status: needs investigation Needs further investigation and removed status: awaiting reporter feedback Awaiting feedback from reporter labels Aug 21, 2023
@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 GaryJones added status: awaiting reporter feedback Awaiting feedback from reporter and removed status: needs investigation Needs further investigation labels Aug 21, 2023
@GaryJones GaryJones added this to the 3.5.14 milestone Aug 25, 2023
@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

@GaryJones GaryJones removed the status: awaiting reporter feedback Awaiting feedback from reporter label Aug 25, 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.

@GaryJones GaryJones merged commit 723534c into master Aug 25, 2023
@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

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants