Skip to content

Fix Move activity losing target when sent to followers#3102

Open
pfefferle wants to merge 2 commits intotrunkfrom
fix/move-activity-target
Open

Fix Move activity losing target when sent to followers#3102
pfefferle wants to merge 2 commits intotrunkfrom
fix/move-activity-target

Conversation

@pfefferle
Copy link
Member

Fixes https://wordpress.org/support/topic/unmigrate-followers/

Proposed changes:

  • Remove the buggy outbox_activity filter for Move activities that was overwriting the target with the object value. This caused all outgoing Move activities to have origin == target, so remote instances correctly ignored them as no-ops. The stored outbox JSON already has the correct values, making the filter unnecessary.
  • Fix verify_move to use camelCase JSON keys (alsoKnownAs) matching raw HTTP responses from Http::get_remote_object(), which returns json_decode'd data without key transformation.
  • Broaden origin matching in verify_move to check id, url, and webfinger identifiers against the target's alsoKnownAs array.

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Set up two accounts: a local WordPress site with ActivityPub and an external account (e.g. Mastodon).
  • Configure account aliases so both accounts reference each other via alsoKnownAs.
  • Run wp activitypub move <local-actor-url> <remote-actor-url> to trigger an external Move.
  • Verify the outbox contains a Move activity where target points to the remote account (not the local one).
  • Verify followers on remote instances receive the Move and migrate accordingly.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch

Type

  • Fixed - for any bug fixes

Message

Fix account migration (Move) not working when moving back to an external account.

The outbox_activity filter for Move activities was overwriting the
target with the object value, causing all outgoing Move activities
to have origin == target. Remote instances correctly ignored these
as no-ops. Fix by removing the unnecessary filter entirely — the
stored outbox JSON already has the correct values.

Also fix verify_move to use camelCase JSON keys (alsoKnownAs) matching
raw HTTP responses, and broaden origin matching to check id, url, and
webfinger identifiers.
Copilot AI review requested due to automatic review settings March 25, 2026 17:01
@pfefferle pfefferle added the Bug Something isn't working label Mar 25, 2026
@pfefferle pfefferle self-assigned this Mar 25, 2026
@pfefferle pfefferle requested a review from a team March 25, 2026 17:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ActivityPub account migration (Move) issues where outgoing Move activities could lose their intended target, and improves inbound Move verification to match real-world actor JSON shapes.

Changes:

  • Removed the activitypub_get_outbox_activity filter for Move activities that could overwrite target.
  • Updated inbound Move verification to use alsoKnownAs (camelCase) and to match origin via id, url, or webfinger.
  • Updated/added PHPUnit coverage for Move handler scenarios and key casing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
includes/handler/class-move.php Removes the outbox filter for Move; updates verify_move() to use alsoKnownAs and broaden origin matching.
tests/phpunit/tests/includes/handler/class-test-move.php Updates mocked actor payload keys to alsoKnownAs; adds tests for origin matching by url and webfinger.
tests/phpunit/tests/includes/class-test-move.php Updates test fixture JSON to use alsoKnownAs.
.github/changelog/fix-move-activity-target Adds a changelog entry documenting the fix.

Some JSON-LD payloads may represent single-value properties as a
string rather than an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants