use custom (more error tolerant) version for migration

This commit is contained in:
Matthias Pfefferle 2023-05-03 14:50:36 +02:00
parent be0f25f3d3
commit 72f72e79b8

View file

@ -1,6 +1,8 @@
<?php <?php
namespace Activitypub; namespace Activitypub;
use Acctivitypub\Model\Follower;
class Migration { class Migration {
public static function init() { public static function init() {
\add_action( 'activitypub_schedule_migration', array( self::class, 'maybe_migrate' ) ); \add_action( 'activitypub_schedule_migration', array( self::class, 'maybe_migrate' ) );
@ -58,7 +60,21 @@ class Migration {
if ( $followers ) { if ( $followers ) {
foreach ( $followers as $follower ) { foreach ( $followers as $follower ) {
Collection\Followers::add_follower( $user_id, $follower ); $meta = get_remote_metadata_by_actor( $actor );
$follower = new Follower( $actor );
if ( is_tombstone( $meta ) ) {
continue;
} if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
$follower->set_error( $meta );
} else {
$follower->from_meta( $meta );
}
$follower->upsert();
$result = wp_set_object_terms( $user_id, $follower->get_actor(), self::TAXONOMY, true );
} }
} }
} }