Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10238 closed defect (bug) (fixed)

A failed upload loses its error messages

Reported by: filosofo Owned by: westi
Priority: high Milestone: 2.8.1
Component: Media Version: 2.8
Severity: major Keywords: media_upload_form_handler has-patch upload
Cc:

Description

If there are errors in some uploads, WP fails to report it because the errors are erased. That happens because the $errors variable is initialized at the top of media_upload_form_handler() to an empty array (new behavior in 2.8), but lines like 490 of wp-admin/includes/media.php set $errors to the (sometimes empty) $return variable returned by media_upload_form_handler() when that $return variable is an array.

Prior to 2.8, the behavior was that media_upload_form_handler() would return NULL, so $errors would remain. Now, media_upload_form_handler() returns an empty array, and $errors is set to that empty array.

Patch initializes $errors in media_upload_form_handler() to NULL.

I think this is related to #10153 among others.

Attachments (1)

dont_lose_error_msgs.10238.diff (1.5 KB) - added by filosofo 4 years ago.

Download all attachments as: .zip

Change History (9)

Updated patch to include a fix for a related problem in wp-admin/media-upload.php

The problem is that it redirects too soon before checking for upload errors. You can test this problem by not having a writable uploads directory and trying to upload from the "Add new" page under Media--nothing happens and you get no feedback.

comment:2   ryan4 years ago

See [11492]

comment:3   ryan4 years ago

Tested patch with browser and flash uploaders from both the edit post page and the new media page.

comment:4   ryan4 years ago

  • Owner set to westi
  • Status changed from new to assigned

comment:5 follow-up: ↓ 6   ryan4 years ago

Tested the failure case where the server goes away. With and without the patch produced an I/O error notice. Did you simulate any error conditions?

comment:6 in reply to: ↑ 5   filosofo4 years ago

Replying to ryan:

Did you simulate any error conditions?

Yes, two:

  • Made the uploads directory unwritable
  • got rid of PHP's tmp directory

I was using only the browser uploader for my tests, however. I think that the browser uploader would fail to print messages more often than the Flash / Ajax uploader, because of the redirection issue.

comment:7   ryan4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [11638]) Don't lose upload error messages. Props filosofo. fixes #10238 for trunk

comment:8   ryan4 years ago

(In [11639]) Don't lose upload error messages. Props filosofo. fixes #10238 for 2.8.1

Note: See TracTickets for help on using tickets.