Make WordPress Core

Opened 15 months ago

Last modified 14 months ago

#47987 closed task (blessed)

REST API: Add handling of PHP fatal errors while resizing images after upload — at Version 4

Reported by: azaozz Owned by:
Milestone: 5.3 Priority: highest omg bbq
Severity: normal Version:
Component: REST API Keywords: dev-feedback
Focuses: Cc:

Description (last modified by azaozz)

Update WP_REST_Attachments_Controller to be able to handle subsequent requests for making missing image sub-sizes similarly to #47872.

Change History (4)

#1 @azaozz
15 months ago

Generally when uploading an image the client should be able to send an unique "upload reference" which is then stored in a transient for one hour, and deleted if all image sub-sizes were created successfully. See
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/media.php?rev=45934#L379 and

Then if the response is HTTP 500, the client should be able to do another request including the upload reference from above, and the server should try to make any missing image sub-sizes. The upload reference is used to find the new attachment ID as the client doesn't know it yet. On the server side that would work similarly to:

Then, if all attempts fail, the client should be able to do a "cleanup": delete the just created attachment. Again, the upload reference is used to find the attachment ID.

And lastly, the error message shown should be... More helpful than the default "This site is experiencing difficulties...". That could be on the client side though.

This is now implemented in #47872 for the media library screen, Add New media (old upload UI), and the media modal. Any suggestions for improvements welcome :)

Last edited 15 months ago by azaozz (previous) (diff)

This ticket was mentioned in Slack in #core-editor by azaozz. View the logs.

15 months ago

This ticket was mentioned in Slack in #core-restapi by timothybjacobs. View the logs.

15 months ago

#4 @azaozz
15 months ago

  • Description modified (diff)
  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.