From 084f10816195bb5bc49fa15d5140c512c5824a17 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 31 May 2023 10:48:51 +0200 Subject: [PATCH] only schedule migration if DB is not on the latest version --- includes/class-scheduler.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/includes/class-scheduler.php b/includes/class-scheduler.php index a79044e..07926d8 100644 --- a/includes/class-scheduler.php +++ b/includes/class-scheduler.php @@ -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' ); + } + } }