[wp-trac] [WordPress Trac] #39647: Make media upload "HTTP error." more user-helpful
WordPress Trac
noreply at wordpress.org
Thu Jun 20 14:31:42 UTC 2019
#39647: Make media upload "HTTP error." more user-helpful
--------------------------+---------------------------------
Reporter: mikeschroder | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Media | Version: 3.4
Severity: normal | Resolution:
Keywords: | Focuses: ui, administration
--------------------------+---------------------------------
Comment (by ramon fincken):
I have been working in catching the PHP error using a 6 second timeout and
@azaozz 'es multi subsizes plugin
https://core.trac.wordpress.org/ticket/40439#comment:48
What happens : we add {{{
<?php
header( 'X-WP-lasterror-message: '.$r['last_error_message'] );
}}}
which can be read in the JavaScript frontend. (yes it will need more user
friendly-ness)
It needs this PHP patch plus this for JS
OPEN
wp-includes/js/plupload/handlers.js
FIND
{{{
function uploadError(fileObj, errorCode, message, uploader) {
}}}
REPLACE WITH
{{{
function uploadError(fileObj, errorCode, message, responseHeaders,
uploader) {
}}}
FIND
{{{
case plupload.HTTP_ERROR:
wpQueueError(pluploadL10n.http_error);
break
}}}
REPLACE WITH
{{{
case plupload.HTTP_ERROR:
message = pluploadL10n.http_error;
var myRegexp = /x-wp-lasterror-message: (.*)/gm;
var match = myRegexp.exec( responseHeaders );
if( match[1] ) {
message += ' ' + match[1];
}
wpQueueError(message);
break
}}}
FIND
{{{
uploader.bind('Error', function(up, err) {
uploadError(err.file, err.code, err.message, up);
up.refresh();
});
}}}
REPLACE WITH
{{{
uploader.bind('Error', function(up, err) {
uploadError(err.file, err.code, err.message,
err.responseHeaders, up);
up.refresh();
});
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39647#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list