[wp-trac] [WordPress Trac] #52569: Don't let PHP timeout in the middle of an ImageMagick operation

WordPress Trac noreply at wordpress.org
Thu Feb 18 18:44:05 UTC 2021


#52569: Don't let PHP timeout in the middle of an ImageMagick operation
--------------------------+-----------------------------
 Reporter:  drzraf        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  5.6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Depending on configuration **Imagick processing may take time**.

 Multiple problems exist if **PHP timeout before the ImageMagick
 completed**:
 1. Temporary files aren't cleaned by ImageMagick garbage collection
 2. No clear error is provided
 3. The cause of such timeout can be hard to pinpoint.

 This new helper is expected to be run before heavy image routines and
 resolves above point 1 by aligning Imagick's timeout on PHP one (assuming
 it's set).

 Note: Imagick resource exhaustion do not catchable issue exceptions (but
 that would be nice to have since we would now be able to handle them).



 Actual incident:

 One of our declared image size was 3000px wide. But that post was given a
 mobile (portait-oriented image of 3000px high and only 1666px wide).

 The Resizing-logic triggered `WP_Image_Editor_Imagick::thumbnail_image()`.
 But while `resizeImage` would take (only) ~2 seconds, `unsharpMaskImage`
 is much more expensive, especially on such big image and was taking
 **way** more time than PHP's timeout.

 The thread (and the Imagemagick process) was killed, but doing so
 brutally, ImageMagick  left a 128MB temporary-file inside `/tmp` every
 time the same HTTP request was triggered.

 Said request coming from the frontend (lazy image-resizing) it quickly
 filled said partition until it disrupted httpd.

 That's why I set this ticket's to "defect".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52569>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list