[wp-trac] [WordPress Trac] #63764: ImageMagick writeImage() causes duplicate inotify events during thumbnail generation

WordPress Trac noreply at wordpress.org
Tue Jul 29 06:13:59 UTC 2025


#63764: ImageMagick writeImage() causes duplicate inotify events during thumbnail
generation
--------------------------+-----------------------------
 Reporter:  agiabanis     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  6.8.2
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 When WordPress generates image thumbnails using ImageMagick, the
 `writeImage()` method in `wp-includes/class-wp-image-editor-imagick.php`
 causes duplicate `CLOSE_WRITE,CLOSE` inotify events.
 Steps to reproduce:
 1. Upload an image to WordPress
 2. Monitor inotify events: `inotifywait -m -e close_write /wp-
 content/uploads/`
 3. Observe duplicate events for each thumbnail

 Expected behavior:
 One `CLOSE_WRITE,CLOSE` event per thumbnail file

 Actual behavior:
 Two `CLOSE_WRITE,CLOSE` events per thumbnail file

 Root cause:
 The `writeImage()` method performs internal buffering that creates two
 file operations:
 1. Write data to buffer
 2. Flush buffer to file

 Proposed fix:
 Replace `writeImage()` with `getImageBlob()` + `file_put_contents()` for
 single operation.

 Files affected:
 - wp-includes/class-wp-image-editor-imagick.php (line 976)

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


More information about the wp-trac mailing list