Opened 4 years ago
Closed 4 years ago
#50711 closed defect (bug) (fixed)
REST API, Media: Fix retrying of post-processing of edited images
Reported by: | azaozz | Owned by: | azaozz |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | rest-api | Cc: |
Description
When an image is edited in the block editor, and the server runs out of resources while post-processing it, the retry request(s) to /wp/v2/media/${ attachmentId }/post-process
don't "kick-in".
Attachments (2)
Change History (6)
#2
@
4 years ago
Ideally it can be like 50711-extended.diff, the new attachment post is created and the X-WP-Upload-Attachment-ID
header is set before any edits are applied to the image. Then it can retry on all possible failures. However there are few caveats:
- Standard API errors cannot be HTTP 500 or they will trigger retries.
- Currently on the js side it can only retry to create image sub-sizes. Would need to handle cases (repeat the request) if the server fails while cropping or rotating the image.
Lets improve this in 5.6.
For now lets handle "server crashes" when creating the sub-sizes for the edited image, see 50711.diff. This is where failures are most likely and is same as after uploading new image. Can be committed now and it will start working after https://github.com/WordPress/gutenberg/pull/24081 is fixed upstream.
Mostly caused by mismatch (missing slash) of the path in image-editor.js. Opened https://github.com/WordPress/gutenberg/pull/24081 to fix it. Will also need to set the
X-WP-Upload-Attachment-ID
HTTP header inWP_REST_Attachments_Controller::edit_media_item()
.