Make WordPress Core

Changeset 55872


Ignore:
Timestamp:
05/30/2023 07:44:56 PM (10 months ago)
Author:
johnbillion
Message:

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

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r55827 r55872  
    891891    // If you override this, you must provide $ext and $type!!
    892892    $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
    893     $mimes     = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
     893    $mimes     = isset( $overrides['mimes'] ) ? $overrides['mimes'] : null;
    894894
    895895    // A correct form post will pass this test.
  • trunk/src/wp-includes/functions.php

    r55871 r55872  
    30133013 * @since 2.0.4
    30143014 *
    3015  * @param string   $filename File name or path.
    3016  * @param string[] $mimes    Optional. Array of allowed mime types keyed by their file extension regex.
    3017  *                           Defaults to the result of get_allowed_mime_types().
     3015 * @param string        $filename File name or path.
     3016 * @param string[]|null $mimes    Optional. Array of allowed mime types keyed by their file extension regex.
     3017 *                                Defaults to the result of get_allowed_mime_types().
    30183018 * @return array {
    30193019 *     Values for the extension and mime type.
     
    30543054 * @since 3.0.0
    30553055 *
    3056  * @param string   $file     Full path to the file.
    3057  * @param string   $filename The name of the file (may differ from $file due to $file being
    3058  *                           in a tmp directory).
    3059  * @param string[] $mimes    Optional. Array of allowed mime types keyed by their file extension regex.
    3060  *                           Defaults to the result of get_allowed_mime_types().
     3056 * @param string        $file     Full path to the file.
     3057 * @param string        $filename The name of the file (may differ from $file due to $file being
     3058 *                                in a tmp directory).
     3059 * @param string[]|null $mimes    Optional. Array of allowed mime types keyed by their file extension regex.
     3060 *                                Defaults to the result of get_allowed_mime_types().
    30613061 * @return array {
    30623062 *     Values for the extension, mime type, and corrected filename.
     
    32403240     * @since 5.1.0 The $real_mime parameter was added.
    32413241     *
    3242      * @param array        $wp_check_filetype_and_ext {
     3242     * @param array         $wp_check_filetype_and_ext {
    32433243     *     Values for the extension, mime type, and corrected filename.
    32443244     *
     
    32473247     *     @type string|false $proper_filename File name with its correct extension, or false if it cannot be determined.
    32483248     * }
    3249      * @param string       $file                      Full path to the file.
    3250      * @param string       $filename                  The name of the file (may differ from $file due to
    3251      *                                                $file being in a tmp directory).
    3252      * @param string[]     $mimes                     Array of mime types keyed by their file extension regex.
    3253      * @param string|false $real_mime                 The actual mime type or false if the type cannot be determined.
     3249     * @param string        $file                      Full path to the file.
     3250     * @param string        $filename                  The name of the file (may differ from $file due to
     3251     *                                                 $file being in a tmp directory).
     3252     * @param string[]|null $mimes                     Array of mime types keyed by their file extension regex, or null if
     3253     *                                                 none were provided.
     3254     * @param string|false  $real_mime                 The actual mime type or false if the type cannot be determined.
    32543255     */
    32553256    return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime );
Note: See TracChangeset for help on using the changeset viewer.