Skip to content

Fix fatal error in follower notifications with ActivityPub 7.5.0+ - #661

Merged
akirk merged 2 commits into
mainfrom
fix/issue-660-wp-post-undefined-method
Apr 27, 2026
Merged

Fix fatal error in follower notifications with ActivityPub 7.5.0+#661
akirk merged 2 commits into
mainfrom
fix/issue-660-wp-post-undefined-method

Conversation

@akirk

@akirk akirk commented Apr 26, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #660Call to undefined method WP_Post::get() fatal in class-notifications.php when receiving a follow / unfollow from the Fediverse.

ActivityPub 7.5.0 changed the activitypub_followers_post_follow and activitypub_followers_pre_remove_follower hooks to pass a WP_Post for the follower rather than the (now deprecated) Follower model. The Friends notification handlers were still calling Follower methods on it (get(), get_url(), get_name(), …), throwing E_ERROR. The inbox endpoint then returned HTTP 500, so the sending Mastodon server retried the delivery several times — which is what caused the duplicate notification emails and the missing replies in the UI described in the report.

This PR:

  • Detects when the follower argument is a WP_Post and resolves it to an Activitypub\Activity\Actor via Remote_Actors::get_actor().
  • Computes the avatar via Remote_Actors::get_avatar_url() (the Actor class has no get_icon_url()) and passes it to the email templates as a new icon_url arg.
  • Reads the follow start date from the WP_Post's post_date_gmt for the lost-follower duration calculation.
  • Keeps backward compatibility with the old Follower model in case the hook is still called the old way.

The outgoing-reply duplication mentioned in the issue is a downstream symptom of the same retry loop and should also be resolved once the inbox stops 500ing.

Test plan

  • Have a Mastodon account follow a WordPress user with the Friends + ActivityPub plugins (≥ 7.5.0) installed — confirm a single new-follower email arrives and no fatal is logged.
  • Have the Mastodon account reply to a post — confirm the reply arrives once and shows up in the Friends UI / WP comments.
  • Have the Mastodon account unfollow — confirm a single lost-follower email arrives with the correct duration.
  • Smoke-test outgoing reply from Friends UI — appears once locally, not three times.

Test in WordPress Playground

akirk added 2 commits April 26, 2026 10:11
ActivityPub 7.5.0 changed the activitypub_followers_post_follow and
activitypub_followers_pre_remove_follower hooks to pass a WP_Post for
the follower instead of a Follower model. Calling get(), get_url(),
etc. on the WP_Post threw E_ERROR, which made the inbox endpoint return
HTTP 500 and triggered remote-server retries (duplicate emails, missing
replies in the UI).

Resolve the Actor via Remote_Actors::get_actor() when a WP_Post is
received, compute the icon URL via Remote_Actors::get_avatar_url() (the
Actor class has no get_icon_url()), and read the follow date from the
post date. Templates now read the icon from the new icon_url param.

Fixes #660
The activitypub_followers_post_follow hook is documented as passing
WP_Post|WP_Error; fall back to an early return when the actor fetch
failed instead of fataling on Actor methods. Also corrects the
lost-follower docblock to reference ActivityPub 7.5.0.
@akirk
akirk merged commit d447785 into main Apr 27, 2026
26 checks passed
@akirk
akirk deleted the fix/issue-660-wp-post-undefined-method branch April 27, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant