Ticket #12278: file.php.diff
File file.php.diff, 3.5 KB (added by , 15 years ago) |
---|
-
.php
old new 220 224 * @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file. 221 225 * @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ). 222 226 * @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). 227 * @todo I don't think it's correct to define the error handler for prefilter errors before running extract. -tychay 223 228 */ 224 229 function wp_handle_upload( &$file, $overrides = false, $time = null ) { 225 230 // The default error handler. … … 258 263 // All tests are on by default. Most can be turned off by $override[{test_name}] = false; 259 264 $test_form = true; 260 265 $test_size = true; 266 $test_upload = true; 261 267 262 268 // If you override this, you must provide $ext and $type!!!! 263 269 $test_type = true; … … 269 275 270 276 // A correct form post will pass this test. 271 277 if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) 272 return $upload_error_handler($file, __( 'Invalid form submission.' ));278 return call_user_func($upload_error_handler, $file, __( 'Invalid form submission.' )); 273 279 274 280 // A successful upload will pass this test. It makes no sense to override this one. 275 281 if ( $file['error'] > 0 ) 276 return $upload_error_handler($file, $upload_error_strings[$file['error']] );282 return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']] ); 277 283 278 284 // A non-empty file will pass this test. 279 285 if ( $test_size && !($file['size'] > 0 ) ) 280 return $upload_error_handler( $file, __( '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.' ));286 return call_user_func($upload_error_handler, $file, __( 'File is empty. Please upload something more substantial.' )); 281 287 282 288 // A properly uploaded file will pass this test. There should be no reason to override this one. 283 if ( ! @ is_uploaded_file( $file['tmp_name'] ) )284 return $upload_error_handler($file, __( 'Specified file failed upload test.' ));289 if ( $test_upload && ! @ is_uploaded_file( $file['tmp_name'] ) ) 290 return call_user_func($upload_error_handler, $file, __( 'Specified file failed upload test.' )); 285 291 286 292 // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. 287 293 if ( $test_type ) { … … 289 295 290 296 extract( $wp_filetype ); 291 297 298 /* WPCOM - Limit site admin uploads 292 299 if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) 293 return $upload_error_handler( $file, __( 'File type does not meet security guidelines. Try another.' )); 300 */ 301 if ( !$type || !$ext ) 302 return call_user_func($upload_error_handler, $file, __( 'File type does not meet security guidelines. Try another.' )); 294 303 295 304 if ( !$ext ) 296 305 $ext = ltrim(strrchr($file['name'], '.'), '.'); … … 303 312 304 313 // A writable uploads dir will pass this test. Again, there's no point overriding this one. 305 314 if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) ) 306 return $upload_error_handler($file, $uploads['error'] );315 return call_user_func($upload_error_handler, $file, $uploads['error'] ); 307 316 308 317 $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );