Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#27225 closed defect (bug) (fixed)

Undefined index: error in wp-admin/includes/file.php on line 261

Reported by: tivnet's profile tivnet Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.9 Priority: normal
Severity: normal Version:
Component: Upload Keywords: has-patch commit
Focuses: Cc:

Description

$file['error'] might not be set.
Patch attached.

Attachments (1)

file-php--if-file-error.patch (854 bytes) - added by tivnet 11 years ago.

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
11 years ago

  • Component changed from General to Upload
  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 3.9

According to http://www.php.net/manual/en/features.file-upload.errors.php, $_FILES['...']['error'] is always set, so apparently it can only be missing if it was removed in wp_handle_upload_prefilter filter:
tags/3.8.1/src/wp-admin/includes/file.php#L217.

We do, however, check if it's set in line 223 (added in [12142]), so we might as well do the same here.

Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#2 @tivnet
11 years ago

Whatever they say, here is the error log from my PHP 5.4. I printed error_log(print_r($file, true));

[27-Feb-2014 20:37:40 UTC] PHP Notice:  Undefined index: error in C:\......\wp-admin\includes\file.php on line 261
[27-Feb-2014 20:37:40 UTC] Array
(
    [name] => 20140227_203740_453_0_0_43051.zip
    [type] => application/force-download
    [size] => 271381
    [tmp_name] => C:\tmp\php816F.tmp
)

#3 @SergeyBiryukov
11 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 27319:

Avoid an undefined index notice in wp_handle_upload().

props tivnet.
fixes #27225.

Note: See TracTickets for help on using tickets.