From f3b93e6b3ac4d60c6ad7a7004fe6dad2034dfeaf Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 30 May 2023 19:46:22 +0000 Subject: [PATCH] Media: Correct the fallback value passed to the `$mimes` parameter of `wp_check_filetype_and_ext()` from `_wp_handle_upload()`, and update corresponding documentation. Previously when the `mimes` element was not specified in the overrides array passed to `_wp_handle_upload()` it resulted in boolean false being passed to this parameter, which is incorrect. The fallback value should be `null`. Props platonkristinin, pkbhatt Fixes #58349 Built from https://develop.svn.wordpress.org/trunk@55872 git-svn-id: http://core.svn.wordpress.org/trunk@55384 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 2 +- wp-includes/functions.php | 29 +++++++++++++++-------------- wp-includes/version.php | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index ca1dbb5938..ca75342488 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -890,7 +890,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) { // If you override this, you must provide $ext and $type!! $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; - $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false; + $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : null; // A correct form post will pass this test. if ( $test_form && ( ! isset( $_POST['action'] ) || $_POST['action'] !== $action ) ) { diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d146c9195a..10ad8e8b5e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3012,9 +3012,9 @@ function wp_get_default_extension_for_mime_type( $mime_type ) { * * @since 2.0.4 * - * @param string $filename File name or path. - * @param string[] $mimes Optional. Array of allowed mime types keyed by their file extension regex. - * Defaults to the result of get_allowed_mime_types(). + * @param string $filename File name or path. + * @param string[]|null $mimes Optional. Array of allowed mime types keyed by their file extension regex. + * Defaults to the result of get_allowed_mime_types(). * @return array { * Values for the extension and mime type. * @@ -3053,11 +3053,11 @@ function wp_check_filetype( $filename, $mimes = null ) { * * @since 3.0.0 * - * @param string $file Full path to the file. - * @param string $filename The name of the file (may differ from $file due to $file being - * in a tmp directory). - * @param string[] $mimes Optional. Array of allowed mime types keyed by their file extension regex. - * Defaults to the result of get_allowed_mime_types(). + * @param string $file Full path to the file. + * @param string $filename The name of the file (may differ from $file due to $file being + * in a tmp directory). + * @param string[]|null $mimes Optional. Array of allowed mime types keyed by their file extension regex. + * Defaults to the result of get_allowed_mime_types(). * @return array { * Values for the extension, mime type, and corrected filename. * @@ -3239,18 +3239,19 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { * @since 3.0.0 * @since 5.1.0 The $real_mime parameter was added. * - * @param array $wp_check_filetype_and_ext { + * @param array $wp_check_filetype_and_ext { * Values for the extension, mime type, and corrected filename. * * @type string|false $ext File extension, or false if the file doesn't match a mime type. * @type string|false $type File mime type, or false if the file doesn't match a mime type. * @type string|false $proper_filename File name with its correct extension, or false if it cannot be determined. * } - * @param string $file Full path to the file. - * @param string $filename The name of the file (may differ from $file due to - * $file being in a tmp directory). - * @param string[] $mimes Array of mime types keyed by their file extension regex. - * @param string|false $real_mime The actual mime type or false if the type cannot be determined. + * @param string $file Full path to the file. + * @param string $filename The name of the file (may differ from $file due to + * $file being in a tmp directory). + * @param string[]|null $mimes Array of mime types keyed by their file extension regex, or null if + * none were provided. + * @param string|false $real_mime The actual mime type or false if the type cannot be determined. */ return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 7a2c14f4d4..0812eb8cfa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55871'; +$wp_version = '6.3-alpha-55872'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.