[wp-trac] [WordPress Trac] #39522: Avoidable PHP Warning thrown in _wp_handle_upload

WordPress Trac noreply at wordpress.org
Mon Jan 9 03:01:42 UTC 2017


#39522: Avoidable PHP Warning thrown in _wp_handle_upload
--------------------------+-----------------------------
 Reporter:  dglingren     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When something goes wrong with an upload, /wp-admin/includes/file.php
 throws a PHP Warning at line 323:

 PHP Warning:  filesize(): stat failed for x in
 C:\Users\dlingren\Documents\My Data\Data Files\Web
 Design\VirtualHosts\mladev\wp-admin\includes\file.php on line 323

 The error is handled by the logic immediately following the offending
 line. Changing the call to "@filesize( ..." would avoid the PHP Warning.
 Here's the code:

 {{{#!php
 <?php
         $test_file_size = 'wp_handle_upload' === $action ? $file['size'] :
 filesize( $file['tmp_name'] );
         // A non-empty file will pass this test.
         if ( $test_size && ! ( $test_file_size > 0 ) ) {
                 if ( is_multisite() ) {
                         $error_msg = __( 'File is empty. Please upload
 something more substantial.' );
                 } else {
                         $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.' );
                 }
                 return call_user_func_array( $upload_error_handler, array(
 &$file, $error_msg ) );
         }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39522>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list