Repository navigation
Fix Scheduler::cleanup_remote_actors to re-fetch with cache bypassed (#3980) - #4072
Open
noruzzamans wants to merge 1 commit into
Open
noruzzamans wants to merge 1 commit into
noruzzamans wants to merge 1 commit into
Conversation
…utomattic#3980) In Scheduler::cleanup_remote_actors(), replace get_remote_metadata_by_actor() with Proxy::get( $guid, array( 'cached' => false ) ) so that faulty actors actually re-fetch remote data instead of short-circuiting to stale cached ap_actor posts. Also address related cleanup behaviors per Automattic#3980: - Only delete immediately on HTTP 410 Gone or a confirmed Tombstone object. Treat HTTP 404 as a regular error so transient network errors do not prematurely purge followers. - Guard against identity drift if the remote response returns an id differing from the actor guid. - Update the known actor in place with Remote_Actors::update() instead of upsert(), avoiding redundant queries. - Pass the actor post ID ($actor->ID) instead of the guid to the scheduled deletion events (activitypub_delete_remote_actor_interactions and activitypub_delete_remote_actor_posts), matching their expected integer post ID. - Add unit test coverage in Test_Scheduler for 404 error incrementation, 410/Tombstone immediate deletion, threshold deletion with post IDs, successful recovery, and ID mismatch guards. Fixes Automattic#3980
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3980
Proposed changes:
In
Scheduler::cleanup_remote_actors(),get_remote_metadata_by_actor()was previously called, which short-circuits to the locally storedap_actorrecord whenever one exists viaRemote_Actors::fetch_by_various(). Because of this, faulty actors always ended up in the success branch, rewriting stale local data and clearing errors, while the Tombstone and 5-error branches never executed.This PR addresses all aspects outlined in #3980:
get_remote_metadata_by_actor()withProxy::get( $guid, array( 'cached' => false ) )to force a genuine remote metadata fetch.Tombstoneobject. HTTP 404 is now treated as a regular error and recorded viaRemote_Actors::add_error(), ensuring transient server misconfigurations do not prematurely purge follower relations.Proxy::get()returns a document declaring anidthat differs from$actor->guid, the cleanup skips the record instead of colliding or corrupting the identity.Remote_Actors::update( $actor->ID, $meta )rather thanupsert(), eliminating redundantget_by_uri()database queries.$actor->ID) instead of$actor->guidtoactivitypub_delete_remote_actor_interactionsandactivitypub_delete_remote_actor_posts, matching what both action handlers have expected since Refactor avatar handling to use remote actor meta #2373.Test_Schedulercovering:Other information:
Testing instructions:
wp cron event run activitypub_cleanup_remote_actorsand confirm error count increments while actor remains.Changelog entry
Changelog Entry Details
Significance
Type
Message
Ensure remote actor cleanup re-fetches metadata with cache bypassed, deletes only on 410 or confirmed tombstones, and schedules cleanups with post ID.