[wp-trac] [WordPress Trac] #48200: Fix the method used to create image sub-sizes when uploading fails with a PHP fatal error

WordPress Trac noreply at wordpress.org
Sun Oct 6 16:50:12 UTC 2019


#48200: Fix the method used to create image sub-sizes when uploading fails with a
PHP fatal error
--------------------------+-----------------------
 Reporter:  azaozz        |       Owner:  azaozz
     Type:  defect (bug)  |      Status:  reopened
 Priority:  high          |   Milestone:  5.3
Component:  Upload        |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+-----------------------

Comment (by azaozz):

 Uh, sorry think I didn't explain well above. I don't mind changing it just
 don't see why this header should be added in different context/under
 different conditions when using the API.

 If we commit 48200.2.diff and
 https://core.trac.wordpress.org/attachment/ticket/47987/47987.5.diff, see
 #47987:

 - Upload from the Media modal:
  - The header is added in `media_handle_upload()` for all uploads, not
 just for images (like currently). Header is not added when calling
 `media_handle_sideload()` and `wp_handle_upload()` directly. These are
 used by some upload plugins, but perhaps we can leave the header out in
 these cases.
  - The header is also added while receiving the AJAX "post-process"
 request for all uploads, not just for images. In the current code the
 header is not added if the attachment is not an image.

 - Uploading using the API:
  - The header is added on the response to the initial upload request
 regardless if the upload is an image or not.
  - Header is not added on responses to requests to the new `post-process`
 end-point.

 Looking at adding header in `wp_ajax_media_create_image_subsizes()`: this
 is just a pass-through as the attachment_id is already known. It may be
 nice to include the `attachment_id` in these cases, makes it clearer to
 the client when there is a HTTP 500 error that this specific attachment
 has problems during post-processing. Perhaps the header should be added to
 the new `post-process` end-point? Alternatively we should remove it from
 `wp_ajax_media_create_image_subsizes()` to make it more inline with the
 API behaviour.

 To only send the information when it is necessary we'll have to look at
 the uploaded file type and set that header only for images (current
 behaviour). However thinking that header can be set for all uploads, like
 in the above patches.

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


More information about the wp-trac mailing list