[wp-trac] [WordPress Trac] #47987: REST API: Add handling of PHP fatal errors while resizing images after upload

WordPress Trac noreply at wordpress.org
Tue Oct 1 18:37:02 UTC 2019


#47987: REST API: Add handling of PHP fatal errors while resizing images after
upload
-------------------------------------------------+-------------------------
 Reporter:  azaozz                               |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  task (blessed)                       |      Status:  accepted
 Priority:  highest omg bbq                      |   Milestone:  5.3
Component:  REST API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests dev-      |     Focuses:
  feedback                                       |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Replying to [comment:21 TimothyBlynJacobs]:

 > To test this, I inserted a `die` at the top of
 `wp_generate_attachment_metadata`. Then did the following requests
 >
 >
 > {{{
 > POST /wp-json/wp/v2/media
 > X-WP-ImageRef: myreference
 > Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
 > file => file
 > alt_text => This is my alt
 > }}}

 Yes, this is the initial upload request. The only thing here is that
 `alt_text => This is my alt` will never be set as the user has not had a
 chance to enter any alt text yet, so it is completely pointless. This is a
 file upload request, no user input is/should be possible other than
 selecting a file to upload :)
 (Not the time to fix that now though).

 > Then...
 >
 > {{{
 > POST /wp-json/wp/v2/media
 > X-WP-RetryImageRef: myreference
 > Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
 > alt_text => This is my alt
 > }}}

 If this is a retry request it should include a "retry" flag, perhaps
 another custom header. Then it won't need to be `multipart/form-data`, can
 actually be a HEAD request, but GET or POST would work too (the request
 body should be empty, there's nothing else to send to the server at this
 time).

 Again, `alt_text => This is my alt` is completely pointless as the user
 cannot set anything there yet. This is still a "file upload" request, step
 two. Lets leave that for now, it is a bug that will need fixing in the
 future.

 Then step three will need another flag in the head. this time that would
 be a "cleanup" instead of "retry".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47987#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list