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
This commit is contained in:
John Blackbourn 2023-05-30 19:46:22 +00:00
parent ffd2a5bb95
commit f3b93e6b3a
3 changed files with 17 additions and 16 deletions

View File

@ -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 ) ) {

View File

@ -3013,7 +3013,7 @@ 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.
* @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.
@ -3056,7 +3056,7 @@ function wp_check_filetype( $filename, $mimes = null ) {
* @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.
* @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.
@ -3249,7 +3249,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
* @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[]|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 );

View File

@ -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.