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

WordPress Trac noreply at wordpress.org
Fri Sep 27 17:32:05 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:  needs-patch      |     Focuses:
-----------------------------+--------------------------------

Comment (by azaozz):

 Replying to [comment:15 TimothyBlynJacobs]:
 > REST semantics wise, the reference isn't describing the actual resource
 itself. It provides information about how the request should be processed;
 metadata.

 Right. Lets go with the header then. I know at some point having "weird"
 HTTP headers resulted in "weird" caching/handling of such requests
 somewhere along the nets, leading to "unexplained", very hard to debug
 edge cases. Hopefully that's all in the past now :)

 > The attachment is created, but the alt text hasn't been saved, the
 additional fields haven't been set, and the `rest_after_insert_attachment`
 hook hasn't fired yet.

 Right, but this is just metadata about the attachment post, not the actual
 post (i.e. the resource). All of these steps can be seen as "post
 processing".

 > It is redundant, but wouldn't result in a duplicate because of the
 presence of the header.

 Yes, I understand. It just seems wasteful to keep sending all the data
 again and again when none of it is needed. Also handling on the client
 will have to be different so it doesn't send/upload the actual file again.
 Seems a bit... unclear but lets just go with it if it is needed.

 > I personally don't think we have enough time to scope out how that would
 work before the deadline for 5.3.

 Yeah, I agree. We are running out of time. Lets just add something that'd
 work. It is a really simple exchange between the client and the server:
 - The client: I want to upload this. Handle it.
 - The server: Crash!!!
 - The client: Hey, what's up with that upload? What happened?
 - The server: Oops, lets try to finish it... Crash again.
 - The client: Hey, what's going on there with my upload?
 - The server: Oops, crashed again. Lets try again...
 ......
 - The client: Well, seems you cannot handle that upload, just do a
 cleanup. Delete all that you got til now. I'll tell the user to try to fix
 it.

 > The REST API supports `$_FILES` or passing the data in the request body.
 So it should be possible to do a direct POST.

 Yeah, the question is how the binary data gets to the PHP `$_FILES` array.
 A `multipart/form-data` request outside the API?

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


More information about the wp-trac mailing list