WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

Revisions: Wrong author shown for Jetpack/Atomic sites

Open rachelmcr opened this issue 7 years ago • 6 comments

Expected behavior

The expected behavior given how the API works now is that the app syncs all authors for a site when it syncs the site details. The revisions API includes the user ID for the author of each revision, and the app uses details from syncing the full list of authors to fill in the Gravatar and username for each revision.

Actual behavior

On Jetpack/Atomic sites, sometimes no author details or the wrong author details appear.

Case 1:

A user reported that on an Atomic site in the app, only one user (the admin/owner of the site) appeared next to all revisions on a post. However, an editor on the site had made some of those revisions, and in WP Admin the editor shows up correctly on those revisions.

In this case, the editor wasn't connected via Jetpack. This is a possible cause for all revisions being attributed to the admin user.

Case 2:

In various tests on Atomic and Jetpack sites, we have seen that no user info appears on the revision. It would be good to better understand why the author wasn't in the author list when the site was synced, and see if we can improve that experience.

cc @danielebogo Internal ref: p4a5px-2m4-p2

rachelmcr avatar Mar 08 '19 11:03 rachelmcr

Thanks @rachelmcr 😊

danielebogo avatar Mar 08 '19 16:03 danielebogo

This issue has been marked as stale because:

  • It has been inactive for the past year.
  • It isn't in a project or a milestone.
  • It hasn’t been labeled [Pri] Blocker, [Pri] High, or good first issue.

Please comment with an update if you believe this issue is still valid or if it can be closed. This issue will also be reviewed for validity and priority (cc @designsimply).

stale[bot] avatar Mar 07 '20 18:03 stale[bot]

We have this issue or a similar one. We recently moved a site off of WordPress.com. The old WordPress.com hosted site and the new self hosted site are both in the WordPress.com account and the new site is connected using JetPack plugin. The blogger continues to post using the WordPress app as they have done in the past but under the new site instead of the old. The problem is that posts show they were authored by the developer's account not the blogger's account. The blogger does not know and has never logged in as the developer yet their posts show they are authored by the developers account. Posting directly on the site instead of using the app works fine.

wddean avatar Jul 19 '21 23:07 wddean

Hello all 👋, I have some information that may help with this issue. When working on https://github.com/wordpress-mobile/WordPress-iOS/pull/16870 recently we noticed what you're observing.

  1. Some user roles can't populate the blog.authors array because the API endpoint won't allow them to query for users. getAuthor will return nil for these roles when called in the RevisionsTableViewController.
  2. Related to Atomic / Jetpack connected sites: If the user can populate the blog.authors array, we found that the user ID attached to revisions is their WP.COM ID, but the author ID in getAuthor is their site-specific ID. In this case, we should be querying getAuthorWith(linkedID: NSNumber) instead.

An example solution could be (though I'm not sure it covers all JP cases):

    private func getAuthor(for id: NSNumber?) -> BlogAuthor? {
        guard let authorId = id, let blog = post?.blog else {
            return nil
        }
        
        if blog.isAtomic() {
            return blog.getAuthorWith(linkedID: authorId)
        }

        return blog.getAuthorWith(id: authorId)
    }

twstokes avatar Aug 03 '21 15:08 twstokes

Thanks for reporting! 👍

dangermattic avatar Dec 20 '24 12:12 dangermattic

Status update (2026-10-28, trunk at 5f78984fbd). Still happens, now proven on a simulator, with a verified fix.

What happens

On a Jetpack-connected site, the Revisions list shows no author. Each row has a blank avatar and the revision date where the author's name should be. The post list shows the same post's author correctly.

Post list Revisions today Revisions with the fix
Post list row: “Oct 21, 2026 · admin”, Reader test: embeds Revisions row with a blank avatar and the date “Oct 21, 2026” instead of an author Revisions row showing the author “admin” (avatar covered)

Repro: a Jetpack-connected site (here, a team test site), a post with at least one revision, then open the post → editor ⋯ menu → Revisions (N). Jetpack Debug, iOS 27.0 simulator.

Root cause

The two IDs don't match:

  • The revisions API reports the author's WordPress.com user ID. On our test site, GET /rest/v1.1/sites/<id>/post/<id>/diffs returned "post_author": "742098".
  • The site's author list is keyed by the site's own user ID. The same person is user 2 on that site, with linked_user_ID: 742098.
  • RevisionsTableViewController.getAuthor(for:) only calls blog.getAuthorWith(id:), so the lookup finds nobody and the row falls back to the date.

On WordPress.com Simple sites both IDs are the same, which is why it only shows up on Jetpack and Atomic sites.

Fix

Fall back to the WordPress.com ID. Blog.getAuthorWith(linkedID:) already exists, and comments use it for the same reason (3943de69e9):

@@ -99,7 +99,9 @@ private extension RevisionsTableViewController {
             return nil
         }
 
-        return post?.blog.getAuthorWith(id: authorId)
+        // Revisions report the author's WordPress.com user ID. On Jetpack and Atomic sites
+        // that differs from the site's own user ID, so fall back to the linked ID.
+        return post?.blog.getAuthorWith(id: authorId) ?? post?.blog.getAuthorWith(linkedID: authorId)
     }
 
     private func getRevisionState(at indexPath: IndexPath) -> RevisionBrowserState {

Verified on the simulator: with this change, the row shows "admin" and the avatar (right-hand screenshot above).

Not covered: some roles can't fetch the site's author list at all, so the lookup still finds nobody for them. That's a separate gap.

Test plan

  • [ ] Jetpack or Atomic site: Revisions shows the author's name and avatar.
  • [ ] WordPress.com Simple site: unchanged.
  • [ ] Self-hosted site: unchanged.
  • [ ] Unit test: a Blog with a BlogAuthor (userID 2, linkedUserID 742098) resolves both 2 and 742098 to that author. Worth moving the lookup out of the view controller so it can be tested.

jkmassel avatar Oct 29 '26 00:10 jkmassel