Skip to content

Commit d023b9a

Browse files
committed
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develop into trac-64404
2 parents b39b67d + d5cbd3d commit d023b9a

File tree

15 files changed

+167
-64
lines changed

15 files changed

+167
-64
lines changed

src/js/_enqueues/lib/auth-check.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,23 @@
159159
setShowTimeout();
160160
});
161161
}).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
162-
if ( 'wp-auth-check' in data ) {
162+
if ( ! ( 'wp-auth-check' in data ) ) {
163+
return;
164+
}
165+
166+
var showOrHide = function () {
163167
if ( ! data['wp-auth-check'] && wrap.hasClass( 'hidden' ) && ! tempHidden ) {
164168
show();
165169
} else if ( data['wp-auth-check'] && ! wrap.hasClass( 'hidden' ) ) {
166170
hide();
167171
}
172+
};
173+
174+
// This is necessary due to a race condition where the heartbeat-tick event may fire before DOMContentLoaded.
175+
if ( wrap ) {
176+
showOrHide();
177+
} else {
178+
$( showOrHide );
168179
}
169180
});
170181

src/wp-admin/includes/class-wp-ms-sites-list-table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ protected function site_states( $site ) {
674674

675675
if ( ! empty( $site_states ) ) {
676676
$state_count = count( $site_states );
677+
$separator = wp_get_list_item_separator();
677678

678679
$i = 0;
679680

@@ -682,9 +683,9 @@ protected function site_states( $site ) {
682683
foreach ( $site_states as $state ) {
683684
++$i;
684685

685-
$separator = ( $i < $state_count ) ? ', ' : '';
686+
$suffix = ( $i < $state_count ) ? $separator : '';
686687

687-
echo "<span class='post-state'>{$state}{$separator}</span>";
688+
echo "<span class='post-state'>{$state}{$suffix}</span>";
688689
}
689690
}
690691
}

src/wp-admin/includes/file.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,14 +1896,14 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
18961896
$uncompressed_size = 0;
18971897

18981898
// Determine any children directories needed (From within the archive).
1899-
foreach ( $archive_files as $file ) {
1900-
if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
1899+
foreach ( $archive_files as $archive_file ) {
1900+
if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
19011901
continue;
19021902
}
19031903

1904-
$uncompressed_size += $file['size'];
1904+
$uncompressed_size += $archive_file['size'];
19051905

1906-
$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname( $file['filename'] ) );
1906+
$needed_dirs[] = $to . untrailingslashit( $archive_file['folder'] ? $archive_file['filename'] : dirname( $archive_file['filename'] ) );
19071907
}
19081908

19091909
// Enough space to unzip the file and copy its contents, with a 10% buffer.
@@ -1967,22 +1967,22 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
19671967
}
19681968

19691969
// Extract the files from the zip.
1970-
foreach ( $archive_files as $file ) {
1971-
if ( $file['folder'] ) {
1970+
foreach ( $archive_files as $archive_file ) {
1971+
if ( $archive_file['folder'] ) {
19721972
continue;
19731973
}
19741974

1975-
if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
1975+
if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
19761976
continue;
19771977
}
19781978

19791979
// Don't extract invalid files:
1980-
if ( 0 !== validate_file( $file['filename'] ) ) {
1980+
if ( 0 !== validate_file( $archive_file['filename'] ) ) {
19811981
continue;
19821982
}
19831983

1984-
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE ) ) {
1985-
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
1984+
if ( ! $wp_filesystem->put_contents( $to . $archive_file['filename'], $archive_file['content'], FS_CHMOD_FILE ) ) {
1985+
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $archive_file['filename'] );
19861986
}
19871987
}
19881988

src/wp-admin/includes/template.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ function _post_states( $post, $display = true ) {
22512251

22522252
if ( ! empty( $post_states ) ) {
22532253
$state_count = count( $post_states );
2254+
$separator = wp_get_list_item_separator();
22542255

22552256
$i = 0;
22562257

@@ -2259,9 +2260,9 @@ function _post_states( $post, $display = true ) {
22592260
foreach ( $post_states as $state ) {
22602261
++$i;
22612262

2262-
$separator = ( $i < $state_count ) ? ', ' : '';
2263+
$suffix = ( $i < $state_count ) ? $separator : '';
22632264

2264-
$post_states_html .= "<span class='post-state'>{$state}{$separator}</span>";
2265+
$post_states_html .= "<span class='post-state'>{$state}{$suffix}</span>";
22652266
}
22662267
}
22672268

@@ -2379,6 +2380,7 @@ function _media_states( $post, $display = true ) {
23792380

23802381
if ( ! empty( $media_states ) ) {
23812382
$state_count = count( $media_states );
2383+
$separator = wp_get_list_item_separator();
23822384

23832385
$i = 0;
23842386

@@ -2387,9 +2389,9 @@ function _media_states( $post, $display = true ) {
23872389
foreach ( $media_states as $state ) {
23882390
++$i;
23892391

2390-
$separator = ( $i < $state_count ) ? ', ' : '';
2392+
$suffix = ( $i < $state_count ) ? $separator : '';
23912393

2392-
$media_states_string .= "<span class='post-state'>{$state}{$separator}</span>";
2394+
$media_states_string .= "<span class='post-state'>{$state}{$suffix}</span>";
23932395
}
23942396
}
23952397

src/wp-includes/revision.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function wp_save_post_revision( $post_id ) {
187187
$post_has_changed = false;
188188

189189
foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
190-
if ( normalize_whitespace( $post->$field ) !== normalize_whitespace( $latest_revision->$field ) ) {
190+
if ( normalize_whitespace( maybe_serialize( $post->$field ) ) !== normalize_whitespace( maybe_serialize( $latest_revision->$field ) ) ) {
191191
$post_has_changed = true;
192192
break;
193193
}

src/wp-includes/taxonomy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,10 @@ function wp_delete_object_term_relationships( $object_id, $taxonomies ) {
19991999

20002000
foreach ( (array) $taxonomies as $taxonomy ) {
20012001
$term_ids = wp_get_object_terms( $object_id, $taxonomy, array( 'fields' => 'ids' ) );
2002+
if ( ! is_array( $term_ids ) ) {
2003+
// Skip return value in the case of an error or the 'wp_get_object_terms' filter returning an invalid value.
2004+
continue;
2005+
}
20022006
$term_ids = array_map( 'intval', $term_ids );
20032007
wp_remove_object_terms( $object_id, $term_ids, $taxonomy );
20042008
}

tests/phpunit/tests/filesystem/unzipFilePclzip.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function set_up_before_class() {
3737
*/
3838
public function test_should_apply_pre_unzip_file_filters() {
3939
$filter = new MockAction();
40-
add_filter( 'pre_unzip_file', array( $filter, 'filter' ) );
40+
add_filter( 'pre_unzip_file', array( $filter, 'filter' ), 10, 2 );
4141

4242
// Prepare test environment.
4343
$unzip_destination = self::$test_data_dir . 'archive/';
@@ -53,7 +53,8 @@ public function test_should_apply_pre_unzip_file_filters() {
5353
$this->rmdir( $unzip_destination );
5454
$this->delete_folders( $unzip_destination );
5555

56-
$this->assertSame( 1, $filter->get_call_count() );
56+
$this->assertSame( 1, $filter->get_call_count(), 'The filter should be called once.' );
57+
$this->assertSame( self::$test_data_dir . 'archive.zip', $filter->get_args()[0][1], 'The $file parameter should be correct.' );
5758
}
5859

5960
/**
@@ -63,7 +64,7 @@ public function test_should_apply_pre_unzip_file_filters() {
6364
*/
6465
public function test_should_apply_unzip_file_filters() {
6566
$filter = new MockAction();
66-
add_filter( 'unzip_file', array( $filter, 'filter' ) );
67+
add_filter( 'unzip_file', array( $filter, 'filter' ), 10, 2 );
6768

6869
// Prepare test environment.
6970
$unzip_destination = self::$test_data_dir . 'archive/';
@@ -79,6 +80,7 @@ public function test_should_apply_unzip_file_filters() {
7980
$this->rmdir( $unzip_destination );
8081
$this->delete_folders( $unzip_destination );
8182

82-
$this->assertSame( 1, $filter->get_call_count() );
83+
$this->assertSame( 1, $filter->get_call_count(), 'The filter should be called once.' );
84+
$this->assertSame( self::$test_data_dir . 'archive.zip', $filter->get_args()[0][1], 'The $file parameter should be correct.' );
8385
}
8486
}

tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,6 @@ public function test_search_returns_post_types_with_numeric_slugs() {
192192
$this->assertCount( 1, $results );
193193

194194
$results_json = array_map( 'json_decode', $results );
195-
$this->assertEquals( 'wptests_123', $results_json[0]->post_type );
195+
$this->assertSame( 'wptests_123', $results_json[0]->post_type );
196196
}
197197
}

tests/phpunit/tests/pluggable/wpMail.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,12 +666,12 @@ public function test_wp_mail_encoding_does_not_bleed() {
666666
wp_mail( WP_TESTS_EMAIL, 'Looong line testing', $content );
667667

668668
$mailer = tests_retrieve_phpmailer_instance();
669-
$this->assertEquals( 'quoted-printable', $mailer->Encoding );
669+
$this->assertSame( 'quoted-printable', $mailer->Encoding );
670670

671671
wp_mail( WP_TESTS_EMAIL, 'A follow up short email', 'Short email' );
672672

673673
$mailer = tests_retrieve_phpmailer_instance();
674-
$this->assertEquals( '7bit', $mailer->Encoding );
674+
$this->assertSame( '7bit', $mailer->Encoding );
675675
}
676676

677677
/**

tests/phpunit/tests/post/revisions.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,4 +930,63 @@ static function ( $revisions ) {
930930
'The title of the second revision was incorrect.'
931931
);
932932
}
933+
934+
/**
935+
* @ticket 64314
936+
* @covers ::wp_save_post_revision
937+
*/
938+
public function test_wp_save_post_revision_with_array_post_meta() {
939+
// This filter is true by default, but this is explicitly to test looking for differences among non-scalar fields.
940+
add_filter( 'wp_save_post_revision_check_for_changes', '__return_true' );
941+
942+
$post_id = self::factory()->post->create();
943+
$meta_key = 'favorite_things';
944+
945+
// Ensure the post meta is saved with each revision.
946+
add_filter(
947+
'wp_post_revision_meta_keys',
948+
static function ( $meta_keys ) use ( $meta_key ) {
949+
$meta_keys[] = $meta_key;
950+
return $meta_keys;
951+
}
952+
);
953+
954+
// Ensure the post meta are used when determining whether a revision should be saved.
955+
add_filter(
956+
'_wp_post_revision_fields',
957+
static function ( $fields ) use ( $meta_key ) {
958+
$fields[ $meta_key ] = 'Favorite Things';
959+
return $fields;
960+
}
961+
);
962+
963+
// Set initial value.
964+
$initial_favorites = array(
965+
'raindrops on roses',
966+
'whiskers on kittens',
967+
'bright copper kettles',
968+
);
969+
update_post_meta( $post_id, $meta_key, $initial_favorites );
970+
971+
// Save the first revision.
972+
$revision_id_1 = wp_save_post_revision( $post_id );
973+
$this->assertIsInt( $revision_id_1, 'Expected first revision to be created.' );
974+
$this->assertCount( 1, wp_get_post_revisions( $post_id ), 'First revision should be created.' );
975+
$this->assertSame( $initial_favorites, get_post_meta( $revision_id_1, $meta_key, true ), 'Expected first revision post meta to have the initial value.' );
976+
977+
// Save the second revision.
978+
$updated_favorites = array_merge(
979+
$initial_favorites,
980+
array(
981+
'warm woolen mittens',
982+
'crisp apple strudels',
983+
'brown paper packages tied up with strings',
984+
)
985+
);
986+
update_post_meta( $post_id, $meta_key, $updated_favorites );
987+
$revision_id_2 = wp_save_post_revision( $post_id );
988+
$this->assertIsInt( $revision_id_2, 'Expected second revision to be created.' );
989+
$this->assertCount( 2, wp_get_post_revisions( $post_id ), 'Second revision should be created after array field change.' );
990+
$this->assertSame( $updated_favorites, get_post_meta( $revision_id_2, $meta_key, true ), 'Expected second revision post meta to have the updated value.' );
991+
}
933992
}

0 commit comments

Comments
 (0)