Fix fatal error in follower notifications with ActivityPub 7.5.0+ - #661
Merged
Conversation
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.
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.
Summary
Fixes #660 —
Call to undefined method WP_Post::get()fatal inclass-notifications.phpwhen receiving a follow / unfollow from the Fediverse.ActivityPub 7.5.0 changed the
activitypub_followers_post_followandactivitypub_followers_pre_remove_followerhooks to pass aWP_Postfor the follower rather than the (now deprecated)Followermodel. The Friends notification handlers were still callingFollowermethods on it (get(),get_url(),get_name(), …), throwingE_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:
WP_Postand resolves it to anActivitypub\Activity\ActorviaRemote_Actors::get_actor().Remote_Actors::get_avatar_url()(theActorclass has noget_icon_url()) and passes it to the email templates as a newicon_urlarg.WP_Post'spost_date_gmtfor the lost-follower duration calculation.Followermodel 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
Test in WordPress Playground