From 4d29532b9b2046dee3c90109b26c07749bd4ae88 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Wed, 9 Mar 2022 00:46:24 +0000 Subject: [PATCH] Media: Revert query string support for `wp_check_filetype()`. Revert [52829] due to fatal errors in some Multisite configurations. Props dd32, SergeyBiryukov, audrasjb. See #30377. git-svn-id: https://develop.svn.wordpress.org/trunk@52832 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 12 +--- .../tests/functions/wpCheckFiletype.php | 58 ------------------- 2 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 tests/phpunit/tests/functions/wpCheckFiletype.php diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 676eacbe38..82b19ec8f1 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -2981,9 +2981,8 @@ function wp_get_default_extension_for_mime_type( $mime_type ) { * You can optionally define the mime array, if needed. * * @since 2.0.4 - * @since 6.0.0 URLs are now supported. * - * @param string $filename File name, path, or URL. + * @param string $filename File name or path. * @param string[] $mimes Optional. Array of allowed mime types keyed by their file extension regex. * @return array { * Values for the extension and mime type. @@ -2999,15 +2998,6 @@ function wp_check_filetype( $filename, $mimes = null ) { $type = false; $ext = false; - // Strip query args and fragment from filename to reveal extension. - $query_pos = strpos( $filename, '?' ); - - if ( false !== $query_pos ) { - $filename = substr_replace( $filename, '', $query_pos ); - } - - $filename = strip_fragment_from_url( $filename ); - foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!\.(' . $ext_preg . ')$!i'; if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { diff --git a/tests/phpunit/tests/functions/wpCheckFiletype.php b/tests/phpunit/tests/functions/wpCheckFiletype.php deleted file mode 100644 index d479c6e9a0..0000000000 --- a/tests/phpunit/tests/functions/wpCheckFiletype.php +++ /dev/null @@ -1,58 +0,0 @@ -assertSame( $expected, $filetype['ext'] ); - } -}