WordPress.org

Make WordPress Core

Changeset 28450


Ignore:
Timestamp:
05/16/2014 04:10:00 PM (7 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_handle_upload().

See #22400.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r28417 r28450  
    225225    // You may define your own function and pass the name in $overrides['upload_error_handler']
    226226    $upload_error_handler = 'wp_handle_upload_error';
     227    if ( isset( $overrides['upload_error_handler'] ) ) {
     228        $upload_error_handler = $overrides['upload_error_handler'];
     229    }
    227230
    228231    // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
     
    230233        return $upload_error_handler( $file, $file['error'] );
    231234
     235    // Install user overrides. Did we mention that this voids your warranty?
     236
    232237    // You may define your own function and pass the name in $overrides['unique_filename_callback']
    233238    $unique_filename_callback = null;
     239    if ( isset( $overrides['unique_filename_callback'] ) ) {
     240        $unique_filename_callback = $overrides['unique_filename_callback'];
     241    }
    234242
    235243    // $_POST['action'] must be set and its value must equal $overrides['action'] or this:
    236244    $action = 'wp_handle_upload';
     245    if ( isset( $overrides['action'] ) ) {
     246        $action = $overrides['action'];
     247    }
    237248
    238249    // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
     
    247258        __( "File upload stopped by extension." ));
    248259
     260    // this may not have orignially been intended to be overrideable, but historically has been
     261    if ( isset( $overrides['upload_error_strings'] ) ) {
     262        $upload_error_strings = $overrides['upload_error_strings'];
     263    }
     264
    249265    // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
    250     $test_form = true;
    251     $test_size = true;
    252     $test_upload = true;
     266    $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true;
     267    $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;
     268    $test_upload = isset( $overrides['test_upload'] ) ? $overrides['test_upload'] : true;
    253269
    254270    // If you override this, you must provide $ext and $type!!!!
    255     $test_type = true;
    256     $mimes = false;
    257 
    258     // Install user overrides. Did we mention that this voids your warranty?
    259     if ( is_array( $overrides ) )
    260         extract( $overrides, EXTR_OVERWRITE );
     271    $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
     272    $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
    261273
    262274    // A correct form post will pass this test.
    263     if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
    264         return call_user_func($upload_error_handler, $file, __( 'Invalid form submission.' ));
    265 
     275    if ( $test_form && ( ! isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) {
     276        return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );
     277    }
    266278    // A successful upload will pass this test. It makes no sense to override this one.
    267279    if ( isset( $file['error'] ) && $file['error'] > 0 ) {
Note: See TracChangeset for help on using the changeset viewer.