Opened 5 months ago
Last modified 5 months ago
#63764 assigned defect (bug)
ImageMagick writeImage() causes duplicate inotify events during thumbnail generation
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 6.8.2 |
| Component: | Media | Keywords: | has-patch |
| Focuses: | Cc: |
Description
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:
- Upload an image to WordPress
- Monitor inotify events:
inotifywait -m -e close_write /wp-content/uploads/ - 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:
- Write data to buffer
- 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)
Attachments (1)
Change History (2)
This ticket was mentioned in PR #9342 on WordPress/wordpress-develop by @agiabanis.
5 months ago
#1
Note: See
TracTickets for help on using
tickets.
Fixes duplicate CLOSE_WRITE,CLOSE events during thumbnail generation by replacing ImageMagick's writeImage() method with a combination of getImageBlob() and file_put_contents() for single file operation.
This eliminates the internal buffering that causes two file operations:
Benefits: