Eliminate the use of `extract()` in `wp_check_filetype_and_ext()`.

See #22400.


git-svn-id: https://develop.svn.wordpress.org/trunk@28426 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-05-15 06:21:51 +00:00
parent 6dd449551e
commit bb4ea7ae3f
1 changed files with 8 additions and 5 deletions

View File

@ -1987,11 +1987,13 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
// Do basic extension validation and MIME mapping
$wp_filetype = wp_check_filetype( $filename, $mimes );
extract( $wp_filetype );
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
// We can't do any further validation without a file to work with
if ( ! file_exists( $file ) )
if ( ! file_exists( $file ) ) {
return compact( 'ext', 'type', 'proper_filename' );
}
// We're able to validate images using GD
if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
@ -2023,12 +2025,13 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
$filename_parts[] = $mime_to_ext[ $imgstats['mime'] ];
$new_filename = implode( '.', $filename_parts );
if ( $new_filename != $filename )
if ( $new_filename != $filename ) {
$proper_filename = $new_filename; // Mark that it changed
}
// Redefine the extension / MIME
$wp_filetype = wp_check_filetype( $new_filename, $mimes );
extract( $wp_filetype );
$ext = $wp_filetype['ext'];
$type = $wp_filetype['type'];
}
}
}