WordPress.org

Make WordPress Core

Ticket #37570: 37570.diff

File 37570.diff, 3.1 KB (added by jbrinley, 5 years ago)

Replace call_user_func with call_user_func_array

  • src/wp-admin/includes/file.php

    diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
    index 6bb61cf..a0ef92d 100644
    function _wp_handle_upload( &$file, $overrides, $time, $action ) { 
    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'] );
    function _wp_handle_upload( &$file, $overrides, $time, $action ) { 
    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.
    function _wp_handle_upload( &$file, $overrides, $time, $action ) { 
    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'];
    function _wp_handle_upload( &$file, $overrides, $time, $action ) { 
    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 );