Uploads: Retry to post-process images after HTTP 500 and HTTP 502 errors.
Props mikeschroder, azaozz. Fixes #47872. Built from https://develop.svn.wordpress.org/trunk@46506 git-svn-id: http://core.svn.wordpress.org/trunk@46303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
135bebc55b
commit
49686be2ab
|
@ -427,7 +427,7 @@ jQuery( document ).ready( function( $ ) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attempt to create image sub-sizes when an image was uploaded successfully
|
// Attempt to create image sub-sizes when an image was uploaded successfully
|
||||||
// but the server responded with HTTP 500 error.
|
// but the server responded with an HTTP 500 or 502 error.
|
||||||
tryAgain = function( up, error ) {
|
tryAgain = function( up, error ) {
|
||||||
var file = error.file;
|
var file = error.file;
|
||||||
var times;
|
var times;
|
||||||
|
@ -465,7 +465,7 @@ jQuery( document ).ready( function( $ ) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if ( error.message && error.status !== 500 ) {
|
if ( error.message && error.status !== 500 && error.status !== 502 ) {
|
||||||
wpQueueError( error.message );
|
wpQueueError( error.message );
|
||||||
} else {
|
} else {
|
||||||
wpQueueError( pluploadL10n.http_error_image );
|
wpQueueError( pluploadL10n.http_error_image );
|
||||||
|
@ -505,7 +505,7 @@ jQuery( document ).ready( function( $ ) {
|
||||||
}
|
}
|
||||||
}).fail( function( jqXHR ) {
|
}).fail( function( jqXHR ) {
|
||||||
// If another HTTP 500 error, try try again...
|
// If another HTTP 500 error, try try again...
|
||||||
if ( jqXHR.status === 500 ) {
|
if ( jqXHR.status === 500 || jqXHR.status === 502 ) {
|
||||||
tryAgain( up, error );
|
tryAgain( up, error );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -582,8 +582,8 @@ jQuery( document ).ready( function( $ ) {
|
||||||
var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
|
var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
|
||||||
var status = error && error.status;
|
var status = error && error.status;
|
||||||
|
|
||||||
// If the file is an image and the error is HTTP 500 try to create sub-sizes again.
|
// If the file is an image and the error is HTTP 500 or 502 try to create sub-sizes again.
|
||||||
if ( status === 500 && isImage ) {
|
if ( ( status === 500 || status === 502 ) && isImage ) {
|
||||||
tryAgain( up, error );
|
tryAgain( up, error );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -109,7 +109,7 @@ window.wp = window.wp || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to create image sub-sizes when an image was uploaded successfully
|
* Attempt to create image sub-sizes when an image was uploaded successfully
|
||||||
* but the server responded with HTTP 500 error.
|
* but the server responded with HTTP 500 or 502 error.
|
||||||
*
|
*
|
||||||
* @since 5.3.0
|
* @since 5.3.0
|
||||||
*
|
*
|
||||||
|
@ -184,8 +184,8 @@ window.wp = window.wp || {};
|
||||||
error( message, data, file, 'no-retry' );
|
error( message, data, file, 'no-retry' );
|
||||||
}
|
}
|
||||||
}).fail( function( jqXHR ) {
|
}).fail( function( jqXHR ) {
|
||||||
// If another HTTP 500 error, try try again...
|
// If another HTTP 500 or 502 error, try try again...
|
||||||
if ( jqXHR.status === 500 ) {
|
if ( jqXHR.status === 500 || jqXHR.status === 502 ) {
|
||||||
tryAgain( message, data, file );
|
tryAgain( message, data, file );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -209,8 +209,8 @@ window.wp = window.wp || {};
|
||||||
var isImage = file.type && file.type.indexOf( 'image/' ) === 0;
|
var isImage = file.type && file.type.indexOf( 'image/' ) === 0;
|
||||||
var status = data && data.status;
|
var status = data && data.status;
|
||||||
|
|
||||||
// If the file is an image and the error is HTTP 500 try to create sub-sizes again.
|
// If the file is an image and the error is HTTP 500 or 502 try to create sub-sizes again.
|
||||||
if ( retry !== 'no-retry' && status === 500 && isImage ) {
|
if ( retry !== 'no-retry' && isImage && ( status === 500 || status === 502 ) ) {
|
||||||
tryAgain( message, data, file );
|
tryAgain( message, data, file );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-beta3-46489';
|
$wp_version = '5.3-beta3-46506';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue