only schedule migration if DB is not on the latest version

This commit is contained in:
Matthias Pfefferle 2023-05-31 10:48:51 +02:00
parent c04cf3fc7e
commit 084f108161

View file

@ -19,6 +19,8 @@ class Scheduler {
\add_action( 'activitypub_update_followers', array( self::class, 'update_followers' ) );
\add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) );
\add_action( 'admin_init', array( self::class, 'schedule_migration' ) );
}
/**
@ -135,4 +137,15 @@ class Scheduler {
}
}
}
/**
* Schedule migration if DB-Version is not up to date.
*
* @return void
*/
public static function schedule_migration() {
if ( ! \wp_next_scheduled( 'activitypub_schedule_migration' ) && ! Migration::is_latest_version() ) {
\wp_schedule_single_event( \time(), 'activitypub_schedule_migration' );
}
}
}