#55150 closed enhancement (fixed)
`_wp_attachment_backup_sizes` meta is not deleted when image is restored and IMAGE_EDIT_OVERWRITE is defined
Reported by: | mitogh | Owned by: | joedolson |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
When transformations are applied to an image (rotate, crop, flip) and then the image is restored data remains stored in _wp_attachment_backup_sizes
when the data at this point is no longer used or relevant.
All of this happens when the constant IMAGE_EDIT_OVERWRITE
is defined and is set to true
.
When the constant is not defined multiple backup sizes references are keep in the file system and in the DB so in this context this work as expected.
Steps to replicate:
- Make sure to define the constant
IMAGE_EDIT_OVERWRITE
- Make sure the value of the constant
IMAGE_EDIT_OVERWRITE
is set totrue
. - Upload an image into the media library of WordPress.
- After the media image has been uploaded rotate, crop it or perform any transformation.
- Save the image
- Open the edit menu again into the image and restore the original image.
After the image has been restored values in the meta key _wp_attachment_backup_sizes
would still exist, in this case, the values presented here are the exact same values as sizes property from _wp_attachment_metadata
.
To review the content from the meta you can use a direct DB query or WP CLI using get_post_meta
functions.
So the suggested approach here instead would be to remove this meta key if the image is restored and IMAGE_EDIT_OVERWRITE
is defined and is set as a true
.
This would help make sure a non-needed meta is stored in the meta key if the image was restored. And also to be consistent with the behavior that the edited images are removed if the constant mentioned previously is defined and is set to true
Change History (13)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
2 years ago
This ticket was mentioned in PR #3537 on WordPress/wordpress-develop by jeawhanlee.
2 years ago
#4
- Keywords has-patch added
Deletes the Attachment backup size meta from db when attachment is restored.
Trac ticket: https://core.trac.wordpress.org/ticket/55150
#5
@
2 years ago
- Keywords dev-feedback needs-testing added
Hi there,
Thanks @mitogh for ticket. The PR need testing.
#6
@
23 months ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/3537.diff
Environment
- OS: macOS 11.2.3
- Web Server: Nginx
- PHP: 7.4.30
- WordPress: 6.2-alpha-54642-src
- Browser: Chrome 109.0.5414.87
- Theme: Twenty Twenty-Three
- Active Plugins: No plugins activated
Actual Results
- ✅ Expected result works as expected with patch.
Additional Notes
- I have checked wp_postmeta table to verify the meta_key exists or not.
Before Patch: _wp_attachment_backup_sizes meta_key appears in the wp_postmeta table
After Patch: _wp_attachment_backup_sizes meta_key disappears.
Supplemental Artifacts
Before Patch: https://d.pr/i/i0fStc
After Patch 1 (before restoring image): https://d.pr/i/lc1rJB
After Patch 2 (After restoring the image): https://d.pr/i/cvf2hl
#7
@
23 months ago
Reproduction Report
This report validates that the issue can be reproduced, and the indicated patch addresses the issue.
Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/3537.diff
Environment
- OS: macOS 13.0 (22A380)
- Web Server: nginx/1.23.3
- PHP: 7.4.33
- WordPress: 6.2-alpha-54642-src
- Browser: Chrome Version 108.0.5359.124
- Theme: Twenty Twenty-Three
- Active Plugins:
- None
Actual Results
- ✅ Error condition occurs (reproduced).
- ✅ Issue resolved with patch.
Additional Notes
- I have checked the issue and the patch works well, the "_wp_attachment_backup_sizes" meta_key disappears after the patch.✅
Supplemental Artifacts
- Before patch the original image meta data(Screenshot):https://d.pr/i/Qko5Qm
- Before patch after Transformed image meta data(Screenshot):https://d.pr/i/hqBJcs
- Before patch after the restoration image meta data(Screenshot):https://d.pr/i/sY9Ysg
- After patching the restoration image meta data(Screenshot):https://d.pr/f1x4uR
#8
@
23 months ago
- Focuses performance removed
At first glance, the PR looks ok to me, but I haven't tested widely. @antpb let me know if you need any help with this one. I'm going to remove the performance focus in the meantime and let you handle a 6.2 decision as part of the Media Component milestone.
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
23 months ago
#11
@
23 months ago
- Keywords commit added; dev-feedback needs-testing removed
Looks good. Committing.
@joedolson commented on PR #3537:
23 months ago
#13
Fixed in r55180
Moving to 6.2 to investigate. Thank you for the clear reproduction steps!