-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Bug Description
Follow-up to #228: When editing an image in WordPress core (related: #158), the original image's sizes are backed up. This is primarily to restore them later. If then the original image is restored again or another round of edits to the same image is saved, the edited image's sizes get backed up. There is no way to restore these via the WordPress UI, but WordPress intentionally does not delete any edits at any point, and it keeps their metadata backups as well.
Our WebP uploads module does not behave in the same way with our _wp_attachment_backup_sources
storage: When restoring the original image, the edited image data is not included in that backup anymore, while it is included in core's _wp_attachment_backup_sizes
. Note that this problem only concerns the full
size in any case, because all sub-size sources are included in WordPress's own storage by definition. But it is a bug we need to fix.
This is probably not critical because there's no way to restore them, but it's still a bug in the WebP uploads module based on how WordPress core works. We do keep the files around as expected, but we don't keep the meta data backup around, which makes it even more inconsistent even with our own approach.
Steps to reproduce
- Upload a JPEG image with the WebP Uploads module active. WebP versions are generated in addition to the JPEG versions.
- Edit the image through the WordPress UI (e.g. crop, rotate, anything). Then save.
- View the attachment's
_wp_attachment_backup_sizes
and_wp_attachment_backup_sources
post meta values. Both have the necessary data stored, the first for all individual sizes (includingsources
for each size), the latter just the mainsources
, i.e. for the original image (underfull-orig
, for consistency with the backup sizes). - Now restore the original.
- View the attachment's
_wp_attachment_backup_sizes
and_wp_attachment_backup_sources
post meta values. You will now recognize that the previous edit's file paths etc are present in_wp_attachment_backup_sizes
, but not in_wp_attachment_backup_sources
- the latter still only has thefull-orig
data and is missing the hashed data with references to the previously edited image, which is the problem we need to fix here.