Skip to content

Commit 3993e53

Browse files
committed
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develop into trac-64354-fix-hoisted-css-cascade
2 parents 2fb1c42 + eda8d9d commit 3993e53

File tree

7 files changed

+62
-21
lines changed

7 files changed

+62
-21
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/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/media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,8 +3769,8 @@ function wp_read_audio_metadata( $file ) {
37693769
* @link https://github.com/JamesHeinrich/getID3/blob/master/structure.txt
37703770
*
37713771
* @param array $metadata The metadata returned by getID3::analyze().
3772-
* @return int|false A UNIX timestamp for the media's creation date if available
3773-
* or a boolean FALSE if a timestamp could not be determined.
3772+
* @return int|false A Unix timestamp for the media's creation date if available
3773+
* or a boolean false if the timestamp could not be determined.
37743774
*/
37753775
function wp_get_media_creation_timestamp( $metadata ) {
37763776
$creation_date = false;

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/rest-api/wpRestUrlDetailsController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
4343
/**
4444
* URL placeholder.
4545
*
46+
* Even though the request is being intercepted with a mocked response, it is not fully bypassing the network. The
47+
* REST API endpoint is validating the `url` parameter with `wp_http_validate_url()` which includes a call to
48+
* `gethostbyname()`. So the domain used in the placeholder URL must be valid to ensure it passes a validity check.
49+
*
4650
* @since 5.9.0
4751
*
4852
* @var string
4953
*/
50-
const URL_PLACEHOLDER = 'https://placeholder-site.com';
54+
const URL_PLACEHOLDER = 'https://example.com';
5155

5256
/**
5357
* Array of request args.
@@ -129,9 +133,9 @@ public function test_get_items() {
129133
$this->assertSame(
130134
array(
131135
'title' => 'Example Website — - with encoded content.',
132-
'icon' => 'https://placeholder-site.com/favicon.ico?querystringaddedfortesting',
136+
'icon' => 'https://example.com/favicon.ico?querystringaddedfortesting',
133137
'description' => 'Example description text here. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore.',
134-
'image' => 'https://placeholder-site.com/images/home/screen-themes.png?3',
138+
'image' => 'https://example.com/images/home/screen-themes.png?3',
135139
),
136140
$data
137141
);
@@ -444,7 +448,7 @@ static function ( $response, $url ) {
444448

445449
$this->assertSame( 418, $data['status'], 'Response "status" is not 418' );
446450

447-
$expected = 'Response for URL https://placeholder-site.com altered via rest_prepare_url_details filter';
451+
$expected = 'Response for URL https://example.com altered via rest_prepare_url_details filter';
448452
$this->assertSame( $expected, $data['response'], 'Response "response" is not "' . $expected . '"' );
449453
}
450454

tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,24 @@ public function test_array_of_taxonomies() {
5353

5454
$this->assertSameSets( array( $t2 ), $terms );
5555
}
56+
57+
/**
58+
* @ticket 64406
59+
*/
60+
public function test_delete_when_error() {
61+
$taxonomy_name = 'wptests_tax';
62+
register_taxonomy( $taxonomy_name, 'post' );
63+
$term_id = self::factory()->term->create( array( 'taxonomy' => $taxonomy_name ) );
64+
$object_id = 567;
65+
wp_set_object_terms( $object_id, array( $term_id ), $taxonomy_name );
66+
67+
// Confirm the setup.
68+
$terms = wp_get_object_terms( $object_id, array( $taxonomy_name ), array( 'fields' => 'ids' ) );
69+
$this->assertSame( array( $term_id ), $terms, 'Expected same object terms.' );
70+
71+
// Try wp_delete_object_term_relationships() when the taxonomy is invalid (no change expected).
72+
wp_delete_object_term_relationships( $object_id, 'wptests_taxation' );
73+
$terms = wp_get_object_terms( $object_id, array( $taxonomy_name ), array( 'fields' => 'ids' ) );
74+
$this->assertSame( array( $term_id ), $terms, 'Expected the object terms to be unchanged.' );
75+
}
5676
}

0 commit comments

Comments
 (0)