Skip to content

Commit d8974e6

Browse files
authored
Fix #1970 (#1973)
1 parent 6ff278a commit d8974e6

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Fixed a PHP error that prevented the Follower overview from loading.

includes/class-scheduler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,20 @@ public static function cleanup_remote_actors() {
196196

197197
if ( is_tombstone( $meta ) ) {
198198
\wp_delete_post( $actor->ID );
199-
} elseif ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
199+
} elseif ( empty( $meta ) || ! is_array( $meta ) || \is_wp_error( $meta ) ) {
200200
if ( Actors::count_errors( $actor->ID ) >= 5 ) {
201201
\wp_schedule_single_event( \time(), 'activitypub_delete_actor_interactions', array( $actor->guid ) );
202202
\wp_delete_post( $actor->ID );
203203
} else {
204204
Actors::add_error( $actor->ID, $meta );
205205
}
206206
} else {
207-
Actors::clear_errors( $actor->ID );
207+
$id = Actors::upsert( $meta );
208+
if ( \is_wp_error( $id ) ) {
209+
Actors::add_error( $actor->ID, $id );
210+
} else {
211+
Actors::clear_errors( $actor->ID );
212+
}
208213
}
209214
}
210215
}

includes/collection/class-actors.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,13 @@ public static function get_actor( $post ) {
715715
$json = \get_post_meta( $post->ID, '_activitypub_actor_json', true );
716716
}
717717

718-
return Actor::init_from_json( $json );
718+
$actor = Actor::init_from_json( $json );
719+
720+
if ( \is_wp_error( $actor ) ) {
721+
self::add_error( $post->ID, $actor );
722+
}
723+
724+
return $actor;
719725
}
720726

721727
/**

includes/table/class-followers.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ public function prepare_items() {
199199
);
200200

201201
foreach ( $followers as $follower ) {
202-
$actor = Actors::get_actor( $follower );
202+
$actor = Actors::get_actor( $follower );
203+
204+
if ( \is_wp_error( $actor ) ) {
205+
continue;
206+
}
207+
203208
$url = object_to_uri( $actor->get_url() ?? $actor->get_id() );
204209
$webfinger = Webfinger::uri_to_acct( $url );
205210

includes/table/class-following.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ public function prepare_items() {
229229
);
230230

231231
foreach ( $followings as $following ) {
232-
$actor = Actors::get_actor( $following );
232+
$actor = Actors::get_actor( $following );
233+
234+
if ( \is_wp_error( $actor ) ) {
235+
continue;
236+
}
237+
233238
$url = object_to_uri( $actor->get_url() ?? $actor->get_id() );
234239
$webfinger = Webfinger::uri_to_acct( $url );
235240

0 commit comments

Comments
 (0)