Make WordPress Core

Ticket #32544: 32544.1.patch

File 32544.1.patch, 2.5 KB (added by hozayx, 8 months ago)
  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index 67544bc..eef3bd1 100644
    a b function wp_filesize( $path ) { 
    36033603 * @return string[] Array of mime types keyed by the file extension regex corresponding
    36043604 *                  to those types.
    36053605 */
    3606 function get_allowed_mime_types( $user = null ) {
     3606function get_allowed_mime_types( $user = null, $ignore_user = false ) {
    36073607        $t = wp_get_mime_types();
    36083608
    36093609        unset( $t['swf'], $t['exe'] );
    function get_allowed_mime_types( $user = null ) { 
    36163616        }
    36173617
    36183618        /**
    3619          * Filters the list of allowed mime types and file extensions.
    3620          *
    3621          * @since 2.0.0
    3622          *
    3623          * @param array            $t    Mime types keyed by the file extension regex corresponding to those types.
    3624          * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user).
     3619        * @param array            $t           Mime types keyed by the file extension regex corresponding to
     3620        *                                      those types. 'swf' and 'exe' removed from full list. 'htm|html' also
     3621        *                                      removed depending on '$user' capabilities.
     3622        * @param int|WP_User|null $user        User ID, User object or null if not provided (indicates current user).
     3623        *
     3624        * @param bool             $ignore_user An override flag to return all possible mime types regardless of user.
    36253625         */
    3626         return apply_filters( 'upload_mimes', $t, $user );
     3626        return apply_filters( 'upload_mimes', $t, $user, $ignore_user );
    36273627}
    36283628
    36293629/**
  • tests/phpunit/tests/functions.php

    diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
    index 9d3260a..75918da 100644
    a b class Tests_Functions extends WP_UnitTestCase { 
    22182218                );
    22192219                $this->assertSameSetsWithIndex( $theme_json, $expected_theme_json );
    22202220        }
    2221 }
     2221
     2222        /**
     2223        * @ticket 32544
     2224        */
     2225        function test_get_allowed_mime_types_all() {
     2226                add_filter( 'upload_mimes', array( $this, 'whitelist_test_mime_type_ignore' ), 10, 3 );
     2227                $all_mimes = get_allowed_mime_types( null, true );
     2228                $this->assertArrayHasKey( 'test', $all_mimes );
     2229               
     2230                $mimes = get_allowed_mime_types();
     2231                $this->assertArrayNotHasKey( 'test', $mimes );
     2232        }
     2233
     2234        public function whitelist_test_mime_type_ignore( $mimes, $user_id, $ignore_user ) {
     2235                $mime_types = array( 'test' => 'text/test' );
     2236                if ( $ignore_user ) {
     2237                        $mimes = array_merge( $mime_types, $mimes );
     2238                }
     2239                return $mimes;
     2240        }
     2241}
     2242 No newline at end of file