Fix account move verification and notify followers - #3585
Open
pfefferle wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Improves outgoing ActivityPub account migration (Move) handling to better align with FEP-7628 by verifying targets before persisting movedTo, ensuring link-back validation uses the canonical actor id, and notifying followers via a profile Update after a move.
Changes:
- Adjust
Move::externally()to validate the target’salsoKnownAsagainst the canonical actor id and only persistmovedToafter verification. - Adjust
Move::internally()to record the source URL on the target actor’salsoKnownAs(so the new actor links back). - Add/extend PHPUnit coverage for verified moves, rejected targets, internal moves between distinct local users, and profile-update federation; add changelog entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
includes/class-move.php |
Updates external/internal move validation and adds follower-notification via profile Update scheduling. |
tests/phpunit/tests/includes/class-test-move.php |
Expands tests for verification behavior, follower notification, and internal moves across distinct users. |
.github/changelog/fix-account-move-verification |
Adds a patch-level changelog entry describing the migration fix. |
Comments suppressed due to low confidence (4)
includes/class-move.php:193
schedule_profile_update()runs even whenadd_to_outbox()fails, which can result in profile Updates being federated without a corresponding Move activity.
$outbox_id = add_to_outbox( $activity, null, $user->get__id(), ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC );
/*
* Notify followers of the changed profile on both actors by federating an Update (FEP-7628).
* Queued after the Move so a follower that reacts to `movedTo` still processes the migration first.
tests/phpunit/tests/includes/class-test-move.php:109
- This
pre_http_requestfilter callback is registered with the default accepted-args (1), but the closure declares 0 parameters. That produces “too many arguments” warnings on PHP 7.x and can become an ArgumentCountError on PHP 8+.
$filter = function () use ( $from ) {
tests/phpunit/tests/includes/class-test-move.php:149
- This
pre_http_requestfilter callback is registered with the default accepted-args (1), but the closure declares 0 parameters. That produces “too many arguments” warnings on PHP 7.x and can become an ArgumentCountError on PHP 8+.
$filter = function () {
tests/phpunit/tests/includes/class-test-move.php:205
- This
pre_http_requestfilter callback is registered with the default accepted-args (1), but the closure declares 0 parameters. That produces “too many arguments” warnings on PHP 7.x and can become an ArgumentCountError on PHP 8+.
$filter = function () use ( $from ) {
Comment on lines
+104
to
+108
| // Advertise the move only after the target is verified, so a failed attempt never leaves the actor pointing at an unverified target. | ||
| if ( $user->get__id() > 0 ) { | ||
| \update_user_option( $user->get__id(), 'activitypub_moved_to', $to ); | ||
| } else { | ||
| \update_option( 'activitypub_blog_user_moved_to', $to ); |
Comment on lines
+121
to
+137
| $updates = get_posts( | ||
| array( | ||
| 'post_type' => Outbox::POST_TYPE, | ||
| 'post_status' => 'any', | ||
| 'author' => self::$user_id, | ||
| // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query | ||
| 'meta_query' => array( | ||
| array( | ||
| 'key' => '_activitypub_activity_type', | ||
| 'value' => 'Update', | ||
| ), | ||
| ), | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertNotEmpty( $updates, 'A move should federate a profile Update.' ); | ||
| } |
3 tasks
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.
Proposed changes:
Reviewed the outgoing
Movehandling (Move::externally()/Move::internally()) against FEP-7628 and fixed four things:externally()setmovedTobefore fetching and checking the target, so a failed or unverifiable move left the actor pointing at a destination with noMovefederated.movedTois now written only after the target is verified.Move'sobject(get_id()) against the target'salsoKnownAs, instead of the possibly non-canonical input URL, which is what receiving servers verify against.alsoKnownAson the target.internally()recorded the old URL on the source actor. It now records it on the target, so the new actor links back to the old one and receiving servers accept the move. For a domain change the two resolve to the same actor, so that path is unchanged; for a move between two different local actors the target now links back.Updateso followers refresh the cachedmovedTo/alsoKnownAs. It is queued after theMoveso a follower that reacts tomovedTostill processes the migration first.Delivery is unchanged and already matches FEP-7628: the
Moveis addressed to the old actor's followers.Other information:
Testing instructions:
wp activitypub move <from> <to>(WP-CLI) or trigger a move via the settings.alsoKnownAsdoes not list your actor is rejected and leavesmovedTounset.movedTo, federates theMoveto followers, and federates a profileUpdate.Changelog entry
The changelog entry is already included in the branch (
.github/changelog/fix-account-move-verification), so the auto-create box below is left unchecked.Changelog Entry Details
Significance
Type
Message
Fix Fediverse account migration so a move is verified before it takes effect and reliably reaches your followers on other servers.