From 562a59f5531c26ce642de4987a287e49e3c238cd Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 21 Jul 2020 03:00:04 +0000 Subject: [PATCH] REST API, Media: Add `X-WP-Upload-Attachment-ID` HTTP header to enable retrying of post-processing of edited images if the server runs out of resources. This is the same as after uploading a new image, will do up to five additional requests to let the server create all image sub-sizes. Fixes #50711. Built from https://develop.svn.wordpress.org/trunk@48525 git-svn-id: http://core.svn.wordpress.org/trunk@48287 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-attachments-controller.php | 6 ++++++ wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index e8f2b9a739..f5468c256d 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -581,6 +581,12 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { update_post_meta( $new_attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); } + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { + // Set a custom header with the attachment_id. + // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. + header( 'X-WP-Upload-Attachment-ID: ' . $new_attachment_id ); + } + // Generate image sub-sizes and meta. $new_image_meta = wp_generate_attachment_metadata( $new_attachment_id, $saved['path'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a30d9d4fcf..5a2c060804 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta2-48524'; +$wp_version = '5.5-beta2-48525'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.