Media: In `_wp_handle_upload()` use `call_user_func_array()` to call the upload error handler.
The default error handler `wp_handle_upload_error()` expects a reference for the first parameter but `call_user_func()` doesn't pass parameters by reference. The current code didn't produce any issues until now. PHP 7.0.9 (and PHP 7.1) is now stricter and prevents calling the error handler with a warning: > PHP Warning: Parameter 1 to wp_handle_upload_error() expected to be a reference, value given. To restore the error handler `_wp_handle_upload()` now uses `call_user_func_array()`. Props jbrinley. Props jorbin for review. Fixes #37570. Built from https://develop.svn.wordpress.org/trunk@38235 git-svn-id: http://core.svn.wordpress.org/trunk@38176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5d9f94693e
commit
771fc167b6
|
@ -270,7 +270,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||||
|
|
||||||
// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
|
// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
|
||||||
if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) {
|
if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) {
|
||||||
return $upload_error_handler( $file, $file['error'] );
|
return call_user_func_array( $upload_error_handler, array( &$file, $file['error'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install user overrides. Did we mention that this voids your warranty?
|
// Install user overrides. Did we mention that this voids your warranty?
|
||||||
|
@ -312,11 +312,11 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||||
|
|
||||||
// A correct form post will pass this test.
|
// A correct form post will pass this test.
|
||||||
if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
|
if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
|
||||||
return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );
|
return call_user_func_array( $upload_error_handler, array( &$file, __( 'Invalid form submission.' ) ) );
|
||||||
}
|
}
|
||||||
// A successful upload will pass this test. It makes no sense to override this one.
|
// A successful upload will pass this test. It makes no sense to override this one.
|
||||||
if ( isset( $file['error'] ) && $file['error'] > 0 ) {
|
if ( isset( $file['error'] ) && $file['error'] > 0 ) {
|
||||||
return call_user_func( $upload_error_handler, $file, $upload_error_strings[ $file['error'] ] );
|
return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
|
$test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
|
||||||
|
@ -327,13 +327,13 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||||
} else {
|
} else {
|
||||||
$error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
|
$error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
|
||||||
}
|
}
|
||||||
return call_user_func( $upload_error_handler, $file, $error_msg );
|
return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// A properly uploaded file will pass this test. There should be no reason to override this one.
|
// A properly uploaded file will pass this test. There should be no reason to override this one.
|
||||||
$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
|
$test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
|
||||||
if ( ! $test_uploaded_file ) {
|
if ( ! $test_uploaded_file ) {
|
||||||
return call_user_func( $upload_error_handler, $file, __( 'Specified file failed upload test.' ) );
|
return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
|
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
|
||||||
|
@ -348,7 +348,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||||
$file['name'] = $proper_filename;
|
$file['name'] = $proper_filename;
|
||||||
}
|
}
|
||||||
if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
|
if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
|
||||||
return call_user_func( $upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ) );
|
return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) );
|
||||||
}
|
}
|
||||||
if ( ! $type ) {
|
if ( ! $type ) {
|
||||||
$type = $file['type'];
|
$type = $file['type'];
|
||||||
|
@ -362,7 +362,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||||
* overriding this one.
|
* overriding this one.
|
||||||
*/
|
*/
|
||||||
if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) {
|
if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) {
|
||||||
return call_user_func( $upload_error_handler, $file, $uploads['error'] );
|
return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
|
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-alpha-38234';
|
$wp_version = '4.7-alpha-38235';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue