Skip to content

Commit f8f4aec

Browse files
authored
Merge branch 'trunk' into add/reader
2 parents 389d881 + 5fa1415 commit f8f4aec

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

includes/class-migration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ public static function update_comment_author_emails( $batch_size = 50, $offset =
655655
array(
656656
'number' => $batch_size,
657657
'offset' => $offset,
658+
'orderby' => 'comment_ID',
658659
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
659660
'meta_query' => array(
660661
array(

tests/phpunit/tests/includes/class-test-migration.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public function tear_down() {
120120
foreach ( $outbox_items as $item_id ) {
121121
\wp_delete_post( $item_id, true );
122122
}
123+
124+
parent::tear_down();
123125
}
124126

125127
/**
@@ -594,20 +596,16 @@ public function test_update_comment_author_emails() {
594596
*/
595597
public function test_update_comment_author_emails_batching() {
596598
// Create multiple comments.
597-
$comment_ids = array();
598-
for ( $i = 0; $i < 3; $i++ ) {
599-
$comment_ids[] = self::factory()->comment->create(
600-
array(
601-
'comment_post_ID' => self::$fixtures['posts'][0],
602-
'comment_author' => "Test User $i",
603-
'comment_author_url' => "https://example.com/users/test$i",
604-
'comment_author_email' => '',
605-
'comment_content' => "Test comment $i",
606-
'comment_type' => 'comment',
607-
'comment_meta' => array( 'protocol' => 'activitypub' ),
608-
)
609-
);
610-
}
599+
// Note: We rely on comment_ID ordering (added to migration function) for deterministic batching.
600+
$comment_ids = self::factory()->comment->create_many(
601+
3,
602+
array(
603+
'comment_post_ID' => self::$fixtures['posts'][0],
604+
'comment_author_email' => '',
605+
'comment_type' => 'comment',
606+
'comment_meta' => array( 'protocol' => 'activitypub' ),
607+
)
608+
);
611609

612610
// Mock the HTTP request.
613611
\add_filter( 'pre_http_request', array( $this, 'mock_webfinger' ) );
@@ -630,11 +628,8 @@ public function test_update_comment_author_emails_batching() {
630628
foreach ( $comment_ids as $comment_id ) {
631629
$comment = \get_comment( $comment_id );
632630
$this->assertEquals( '[email protected]', $comment->comment_author_email );
633-
634-
wp_delete_comment( $comment_id, true );
635631
}
636632

637-
_delete_all_data();
638633
\remove_filter( 'pre_http_request', array( $this, 'mock_webfinger' ) );
639634
}
640635

0 commit comments

Comments
 (0)