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

REST API: Fix the comment author object for comments whose author info has been edited. #7707

Merged
merged 1 commit into from
Sep 26, 2017

Conversation

kwight
Copy link
Contributor

@kwight kwight commented Aug 29, 2017

wp-admin allows a user to edit a comment author's name, email, and URL. This can be done for both logged-out and logged-in users.

screen shot 2017-08-28 at 4 18 42 pm

If a comment author is logged-in when commenting, the stored comment will also have the comment author's user ID. The presence of this ID will fail this check in get_author(), and the author object returned by an API call will reflect the user based on that ID; any edited name, email, or URL in the comments table will be bypassed.

This PR seems like the simplest way to get at the edited data: if the "author" passed in is a comment row (as determined by the presence of comment_author_email, which is required when commenting), return data from that comment. Note that this will mean losing the original commenter's user ID and associated avatar in the response, but I think this would be desirable. Otherwise, the comment author will be displayed with their edited email, for example, and an avatar associated to another (the original) email.

Another approach would be to have the same data returned for all authors (get rid of the check referenced above), but override any possible edited commenter's data. However, this could change the nature of the response; it will add an (empty) site_id to author, and ID would no longer be 0 in the case of logged-in and edited comment authors. This would be a more consistent shape, but the effect would be more unpredictable – so I've proposed the former for now.

D7075-code

@kwight kwight requested a review from a team as a code owner August 29, 2017 00:33
@gwwar gwwar added this to the 5.4 milestone Sep 6, 2017
@gwwar gwwar self-requested a review September 6, 2017 21:41
@jeherve jeherve added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Type] Bug When a feature is broken and / or not performing as intended [Feature] WPCOM API labels Sep 8, 2017
Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Verified that comment edits are reflected when running this branch.

One of the dangers here, would be that we could attribute a comment to someone completely different, but if we were concerned with that we wouldn't allow editing of these fields for logged in users.

@dereksmart dereksmart merged commit bc75625 into master Sep 26, 2017
@dereksmart dereksmart deleted the fix/api-comment-author-response branch September 26, 2017 21:33
@dereksmart dereksmart removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Sep 26, 2017
kwight added a commit that referenced this pull request Sep 29, 2017
A previous change in #7707 could lead to incorrect avatars being
displayed on Highlander comments made through Facebook. This fix
restores the `get_avatar_url()` param to its previous `$author` value.
dereksmart pushed a commit that referenced this pull request Sep 29, 2017
A previous change in #7707 could lead to incorrect avatars being
displayed on Highlander comments made through Facebook. This fix
restores the `get_avatar_url()` param to its previous `$author` value.
dereksmart pushed a commit that referenced this pull request Sep 29, 2017
A previous change in #7707 could lead to incorrect avatars being
displayed on Highlander comments made through Facebook. This fix
restores the `get_avatar_url()` param to its previous `$author` value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] WPCOM API [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants