WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 9 months ago

Last modified 9 months ago

#25849 closed enhancement (fixed)

Better Error Messages for the Media Uploader

Reported by: chriscct7 Owned by:
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.7
Component: Media Keywords: needs-patch
Focuses: Cc:

Description

Right now, the error messages the Media Uploader returns are extremely generic.For example:
"An error occurred in the upload. Please try again later."
and "HTTP Error"

This makes it really hard to figure out what the issue is that needs solving.

Better error messaging would be a much appreciated improvement to the media uploader.

Attachments (1)

25849-01.patch (3.7 KB) - added by gcorne 9 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 @johnbillion21 months ago

These generic error messages are used as fallback messages when the specific error is unknown. Typically they should never be shown.

It sounds like an error is happening on your site that is not being accounted for. We could improve these messages by including the error code when it's available (ie. Plupload's error code or SWFUpload's error code) to help with debugging.

comment:2 @SergeyBiryukov21 months ago

  • Type changed from feature request to enhancement
  • Version changed from trunk to 3.7

Related: #19817, #22146, #22869, #23127, #23363.

comment:3 @mordauk10 months ago

  • Keywords needs-patch added

I'd love to see the error codes included. We get this problem with one of our extensions for Easy Digital Downloads all the time. Usually it's related to another plugin or theme causing an issue of some kind, but without error codes it's excruciatingly difficult to troubleshoot.

comment:4 @chriscct710 months ago

One of the plugins I wrote lets users upload files on the frontend using the core WordPress Media Uploader. From our experience in support, there are probably at least a dozen different ways to trigger the exact same generic message listed above, and the only way to find the actual causation for the issue on a site is a very time consuming 1 by 1 crossing off the list of ways we know we can trigger it approach. With better error messages, when the error message is shown, it would let developers, users, and site owners know exactly what the problem is.

Here's a partial of our list of the ways you can trigger that message:

  • lack of permissions (capabilities)
  • lack of memory (overload during upload process)
  • lack of permissions on the upload folder
  • another plugin moving the upload location using the filter to another place that isn't supported (permissions)
  • any sort of blocking to admin-ajax.php (extreme caching, security plugin, htaccess rule) when the upload tab has been defined as the default open to tab in JS
  • the user being logged out during the upload
  • some versions of PHP 5.2 apparently don't play nice with the uploader

There's only 2 ways (at least that I've seen) to get a unique error message:

  • non-supported file type
  • filesize over upload limit

The current error system is really frustrating to work with, as there's no guidance on what the error is. If an error message is to be shown, it should say what triggered it (even if it just wants to give us a list of reasons), so we have some place to start debugging.

@gcorne9 months ago

comment:5 @gcorne9 months ago

As suggested by @chriscct7, there are some improvements that we can make to try and better communicate the nature of errors so that users can pass along errors so that they can be addressed.

  1. Permission errors are not passed as JSON back to the client with some sort of message. While testing, I discovered that the drag and drop interface to upload media is not disabled for users that do not have the upload_files capability, which is what I used to test this.
  1. Multisite size errors are not passed to the client as JSON. See #29891
  1. In cases where there is some sort of server glitch or misconfiguration, the status code of the HTTP response is not provided in the error presented to the user.

In 25849-01.patch, I added better error responses for the permission errors. I also cleaned up the code a bit by using wp_send_json_error() and wp_send_json_success().

comment:6 @johnbillion9 months ago

In 30354:

Add some specific JSON responses when there are user permission errors for AJAX file uploads. Replace some usage of wp_json_encode() with wp_send_json_*().

See #25849
Props gcorne

comment:7 follow-up: @helen9 months ago

  • Milestone changed from Awaiting Review to 4.1

What else needs to happen here?

comment:8 in reply to: ↑ 7 ; follow-up: @johnbillion9 months ago

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

Replying to helen:

What else needs to happen here?

There are some other error scenarios which still result in a generic error message.

chriscct7: Can you open a new ticket with your list of error scenarios and we'll look at handling these in 4.2.

comment:9 in reply to: ↑ 8 @chriscct79 months ago

Replying to johnbillion:
Yep, going to do another sweep at the media manager and make sure the remaining items on that list are still valid, and is comprehensive and then will open another ticket and link back to here.

Replying to helen:

What else needs to happen here?

There are some other error scenarios which still result in a generic error message.

chriscct7: Can you open a new ticket with your list of error scenarios and we'll look at handling these in 4.2.

Note: See TracTickets for help on using tickets.