Skip to content

Evict WordPress clients during account and site removal - #25852

Merged
crazytonyli merged 4 commits into
trunkfrom
feature/wp-client-eviction
Aug 26, 2026
Merged

Evict WordPress clients during account and site removal#25852
crazytonyli merged 4 commits into
trunkfrom
feature/wp-client-eviction

Conversation

@crazytonyli

@crazytonyli crazytonyli commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

WordPressClientFactory caches clients by blog ID. Removing an account or site currently leaves its client cached for the rest of the app session.

This PR evicts clients when removing the default WordPress.com account, explicitly removing a site, or deleting a site that is no longer returned during account sync.

@wpmobilebot

wpmobilebot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33987
VersionPR #25852
Bundle IDorg.wordpress.alpha
Commit80f5646
Installation URL78cf1mhaujnq0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33987
VersionPR #25852
Bundle IDcom.jetpack.alpha
Commit80f5646
Installation URL2mpd154p4gh4o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

@crazytonyli
crazytonyli force-pushed the feature/wp-client-eviction branch from 11a7eff to d0f2aba Compare August 11, 2026 22:48
@crazytonyli
crazytonyli marked this pull request as ready for review August 11, 2026 22:48
@crazytonyli
crazytonyli requested a review from jkmassel August 11, 2026 22:48
@crazytonyli crazytonyli modified the milestones: 27.2, 27.3 Aug 11, 2026
for (Blog *blog in account.blogs) {
if ([toDelete containsObject:blog.dotComID]) {
[self unscheduleBloggingRemindersFor:blog];
[self evictWordPressClientForBlog:blog];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This clears the site's saved connection a moment too soon.

The sync deletes the site in the background, but that delete isn't written to disk until the whole sync finishes. In that gap the site is still on screen. If you tap it right then, the app builds a fresh connection for a site that's about to disappear — undoing the cleanup this line just did. The new connection then sits unused until the next logout.

Steps to see it:

  1. Sign in to WordPress.com with two sites, A and B.
  2. On the web, remove your access to site B.
  3. In the app, pull to refresh. It starts removing B in the background.
  4. Before it finishes, tap B — it's still showing in your list.
  5. The app spins up a brand-new connection for B and starts loading a site that's being deleted.

Fix: do this cleanup after the sync has finished saving the deletion, not before. Once B is really gone, tapping it can't rebuild the connection. (This is a bit more than a one-line change — the cleanup needs to move to where the sync reports it's done — so I've left it as a note rather than a code suggestion.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Based on the steps, the race between step 3 and 4 specifically, it looks like an acceptable edge case? I think the app in general would struggle with this kind of simultaneously deleting from the web and accessing from the app issue. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we speculatively remove the site from the UI if it's pending deletion? I think that would be a workaround.

The repro steps are just a way to demonstrate the issue without actually deleting the site.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see a "pending deletion" state on WP.com. I tried deleting a couple of simple sites and a premium sites. They are all gone pretty quickly. I only have one atomic test site, so I did not try that...

I believe once you delete the site from the app, the site's response says is_deleted is true, which means the site won't show up in the site list.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I mean "pending deletion" locally – the network request is in-flight to delete it, so the site is hidden from view immediately. It makes it so the user can't interact with it.

We could deal with this as a future consideration if needed?

@crazytonyli
crazytonyli requested a review from jkmassel August 25, 2026 07:46
@crazytonyli
crazytonyli force-pushed the feature/wp-client-eviction branch from d0f2aba to a28cfa7 Compare August 26, 2026 02:13

@jkmassel jkmassel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't be able to interact with the app while a site is being deleted, so this is good to merge.

@crazytonyli
crazytonyli enabled auto-merge August 26, 2026 02:37
@crazytonyli
crazytonyli added this pull request to the merge queue Aug 26, 2026
Merged via the queue into trunk with commit ba0c00c Aug 26, 2026
28 checks passed
@crazytonyli
crazytonyli deleted the feature/wp-client-eviction branch August 26, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants