Skip to content

Commit 2d52441

Browse files
authored
Rerun follower migration (#1778)
1 parent 8801b77 commit 2d52441

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
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+
Improved follower migration: scheduler now more reliable and won't stop too early.

includes/class-migration.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ public static function maybe_migrate() {
185185
\wp_schedule_single_event( \time(), 'activitypub_upgrade', array( 'update_actor_json_storage' ) );
186186
}
187187

188+
if ( \version_compare( $version_from_db, 'unreleased', '<' ) ) {
189+
\wp_schedule_single_event( \time(), 'activitypub_upgrade', array( 'update_actor_json_storage' ) );
190+
}
191+
188192
/*
189193
* Add new update routines above this comment. ^
190194
*
@@ -971,19 +975,17 @@ public static function migrate_followers_to_ap_actor_cpt() {
971975
* Update _activitypub_actor_json meta values to ensure they are properly slashed.
972976
*
973977
* @param int $batch_size Optional. Number of meta values to process per batch. Default 100.
974-
* @param int $offset Optional. Number of meta values to skip. Default 0.
975978
*
976979
* @return array|null Array with batch size and offset if there are more meta values to process, null otherwise.
977980
*/
978-
public static function update_actor_json_storage( $batch_size = 100, $offset = 0 ) {
981+
public static function update_actor_json_storage( $batch_size = 100 ) {
979982
global $wpdb;
980983

981984
// phpcs:ignore WordPress.DB.DirectDatabaseQuery
982985
$meta_values = $wpdb->get_results(
983986
$wpdb->prepare(
984-
"SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_activitypub_actor_json' LIMIT %d OFFSET %d",
985-
$batch_size,
986-
$offset
987+
"SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_activitypub_actor_json' LIMIT %d",
988+
$batch_size
987989
)
988990
);
989991

@@ -1030,7 +1032,6 @@ public static function update_actor_json_storage( $batch_size = 100, $offset = 0
10301032
if ( \count( $meta_values ) === $batch_size ) {
10311033
return array(
10321034
'batch_size' => $batch_size,
1033-
'offset' => $offset + $batch_size,
10341035
);
10351036
}
10361037

0 commit comments

Comments
 (0)