WordPress.org

Make WordPress Core

Changeset 28451


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

Eliminate use of extract() in wp_handle_sideload().

See #22400.

File:
1 edited

Legend:

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

    r28450 r28451  
    385385    }
    386386
     387    // Install user overrides. Did we mention that this voids your warranty?
     388
    387389    // You may define your own function and pass the name in $overrides['upload_error_handler']
    388390    $upload_error_handler = 'wp_handle_upload_error';
     391    if ( isset( $overrides['upload_error_handler'] ) ) {
     392        $upload_error_handler = $overrides['upload_error_handler'];
     393    }
    389394
    390395    // You may define your own function and pass the name in $overrides['unique_filename_callback']
    391396    $unique_filename_callback = null;
     397    if ( isset( $overrides['unique_filename_callback'] ) ) {
     398        $unique_filename_callback = $overrides['unique_filename_callback'];
     399    }
    392400
    393401    // $_POST['action'] must be set and its value must equal $overrides['action'] or this:
    394402    $action = 'wp_handle_sideload';
     403    if ( isset( $overrides['action'] ) ) {
     404        $action = $overrides['action'];
     405    }
    395406
    396407    // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
     
    405416        __( "File upload stopped by extension." ));
    406417
     418    // this may not have orignially been intended to be overrideable, but historically has been
     419    if ( isset( $overrides['upload_error_strings'] ) ) {
     420        $upload_error_strings = $overrides['upload_error_strings'];
     421    }
     422
    407423    // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
    408     $test_form = true;
    409     $test_size = true;
     424    $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true;
     425    $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;
    410426
    411427    // If you override this, you must provide $ext and $type!!!!
    412     $test_type = true;
    413     $mimes = false;
    414 
    415     // Install user overrides. Did we mention that this voids your warranty?
    416     if ( is_array( $overrides ) )
    417         extract( $overrides, EXTR_OVERWRITE );
     428    $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
     429    $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
    418430
    419431    // A correct form post will pass this test.
     
    450462            $type = $file['type'];
    451463        }
     464    } else {
     465        $type = '';
    452466    }
    453467
Note: See TracChangeset for help on using the changeset viewer.