[wp-trac] [WordPress Trac] #48451: Regression: wp_update_attachment_metadata filter now fires very often and without complete metadata
WordPress Trac
noreply at wordpress.org
Thu Oct 31 21:11:11 UTC 2019
#48451: Regression: wp_update_attachment_metadata filter now fires very often and
without complete metadata
-------------------------------------------------+---------------------
Reporter: ianmjones | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.3
Component: Media | Version: trunk
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch needs-testing | Focuses:
-------------------------------------------------+---------------------
Changes (by azaozz):
* keywords: needs-patch 2nd-opinion => 2nd-opinion has-patch needs-testing
Comment:
Went through several possible options on how to fix this. It's true that
using `wp_update_attachment_metadata` as a hook that means "file uploaded
successfully" is somewhat non-standard. It is intended for filtering the
actual data before saving it in the DB.
However it seems several plugins use it to continue post-processing after
a file was uploaded. A better hook for that perhaps would be
`wp_generate_attachment_metadata`. At the same time it's true there is a
"change in behaviour" for the `wp_update_attachment_metadata` filter. As
the attachment metadata is updated after each image sub-size is generated,
now it runs several times in a row.
Seems the best way to fix that new behaviour would be to not run
`wp_update_attachment_metadata()` for interim updates of the meta, only
run it at the end after all post-processing has been done successfully.
This change will also prevent firing the `wp_update_attachment_metadata`
filter in cases where the post-processing of an image fails after all
retry attempts and the upload is deemed "unsuccessful" and the attachment
is deleted.
In 48451.diff:
- Do not use `wp_update_attachment_metadata()` for interim updates of the
data while an image is being post-processed after upload.
- Introduce `wp_interim_update_attachment_metadata` filter for these
interim updates.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48451#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list