Make WordPress Core

Ticket #37570: 37570.2.diff

File 37570.2.diff, 3.3 KB (added by ocean90, 9 years ago)
  • src/wp-admin/includes/file.php

     
    270270
    271271        // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
    272272        if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) {
    273                 return $upload_error_handler( $file, $file['error'] );
     273                return call_user_func_array( $upload_error_handler, array( &$file, $file['error'] ) );
    274274        }
    275275
    276276        // Install user overrides. Did we mention that this voids your warranty?
     
    312312
    313313        // A correct form post will pass this test.
    314314        if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
    315                 return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );
     315                return call_user_func_array( $upload_error_handler, array( &$file, __( 'Invalid form submission.' ) ) );
    316316        }
    317317        // A successful upload will pass this test. It makes no sense to override this one.
    318318        if ( isset( $file['error'] ) && $file['error'] > 0 ) {
    319                 return call_user_func( $upload_error_handler, $file, $upload_error_strings[ $file['error'] ] );
     319                return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) );
    320320        }
    321321
    322322        $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] );
     
    327327                } else {
    328328                        $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.' );
    329329                }
    330                 return call_user_func( $upload_error_handler, $file, $error_msg );
     330                return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) );
    331331        }
    332332
    333333        // A properly uploaded file will pass this test. There should be no reason to override this one.
    334334        $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] );
    335335        if ( ! $test_uploaded_file ) {
    336                 return call_user_func( $upload_error_handler, $file, __( 'Specified file failed upload test.' ) );
     336                return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) );
    337337        }
    338338
    339339        // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
     
    348348                        $file['name'] = $proper_filename;
    349349                }
    350350                if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
    351                         return call_user_func( $upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ) );
     351                        return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) );
    352352                }
    353353                if ( ! $type ) {
    354354                        $type = $file['type'];
     
    362362         * overriding this one.
    363363         */
    364364        if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) {
    365                 return call_user_func( $upload_error_handler, $file, $uploads['error'] );
     365                return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) );
    366366        }
    367367
    368368        $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );