call migration!

This commit is contained in:
Matthias Pfefferle 2024-10-17 10:09:48 +02:00
parent 6d3270e4de
commit fb76e8f106
2 changed files with 21 additions and 10 deletions

View file

@ -22,7 +22,7 @@ use WP_CLI;
require_once __DIR__ . '/includes/compat.php';
require_once __DIR__ . '/includes/functions.php';
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '3.3.3' );
\define( 'ACTIVITYPUB_PLUGIN_VERSION', '4.0.0' );
/**
* Initialize the plugin constants.

View file

@ -87,7 +87,7 @@ class Migration {
* @return bool True if the database structure is up to date, false otherwise.
*/
public static function is_latest_version() {
return (bool) version_compare(
return (bool) \version_compare(
self::get_version(),
self::get_target_version(),
'=='
@ -120,23 +120,34 @@ class Migration {
if ( ! \wp_next_scheduled( 'activitypub_migrate', $version_from_db ) ) {
\wp_schedule_single_event( \time(), 'activitypub_migrate', array( $version_from_db ) );
}
if ( version_compare( $version_from_db, '0.17.0', '<' ) ) {
if ( \version_compare( $version_from_db, '0.17.0', '<' ) ) {
self::migrate_from_0_16();
}
if ( version_compare( $version_from_db, '1.3.0', '<' ) ) {
if ( \version_compare( $version_from_db, '1.3.0', '<' ) ) {
self::migrate_from_1_2_0();
}
if ( version_compare( $version_from_db, '2.1.0', '<' ) ) {
if ( \version_compare( $version_from_db, '2.1.0', '<' ) ) {
self::migrate_from_2_0_0();
}
if ( version_compare( $version_from_db, '2.3.0', '<' ) ) {
if ( \version_compare( $version_from_db, '2.3.0', '<' ) ) {
self::migrate_from_2_2_0();
}
if ( version_compare( $version_from_db, '3.0.0', '<' ) ) {
if ( \version_compare( $version_from_db, '3.0.0', '<' ) ) {
self::migrate_from_2_6_0();
}
if ( \version_compare( $version_from_db, '4.0.0', '<' ) ) {
self::migrate_to_4_0_0();
}
update_option( 'activitypub_db_version', self::get_target_version() );
/**
* Fires when the system has to be migrated.
*
* @param string $version_from_db The version from which to migrate.
* @param string $target_version The target version to migrate to.
*/
\do_action( 'activitypub_migrate', $version_from_db, self::get_target_version() );
\update_option( 'activitypub_db_version', self::get_target_version() );
self::unlock();
}
@ -147,7 +158,7 @@ class Migration {
* @param string $version_from_db The version from which to migrate.
*/
public static function async_migration( $version_from_db ) {
if ( version_compare( $version_from_db, '1.0.0', '<' ) ) {
if ( \version_compare( $version_from_db, '1.0.0', '<' ) ) {
self::migrate_from_0_17();
}
}
@ -265,7 +276,7 @@ class Migration {
/**
* Update actor-mode settings.
*/
private static function migrate_from_4_0_0() {
private static function migrate_to_4_0_0() {
$blog_profile = \get_option( 'activitypub_enable_blog_user', false );
$author_profiles = \get_option( 'activitypub_enable_users', false );