[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
Sun Nov 3 18:27:52 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:
-------------------------------------------------+---------------------
Comment (by joemcgill):
After looking through the changes proposed here, I think that @azaozz's
initial suggestion in
[https://core.trac.wordpress.org/ticket/48451#comment1 comment #1] is the
right approach.
Right now, `wp_update_attachment_metadata()` is used everywhere in Core
where an attachment's metadata is being updated—and is the recommended
function that should be used by plugins when updating attachment post meta
for any number of reasons. People are able to reliably hook into the
`wp_update_attachment_metadata` filter to modify attachment post metadata
before it is saved to the database. With the proposed change in
[attachment:"48451.diff"], we would be breaking that assumption and
introducing complexity which means people who need to be able to detect
and modify data before it's written to the database would now have to
listen to multiple different filters depending on why attachment metadata
is being updated. This additional complexity makes the system more brittle
and introduces lots of potential for inconsistencies where bugs can/will
occur.
For example, imagine that some plugin in the future decided to call
`wp_create_image_subsizes()` for some reason. WordPress would update the
post meta for an attachment, but an extension hooked to
`wp_update_attachment_metadata` to move files elsewhere would never be
notified.
I'd prefer that we keep the system consistent and we always call
`wp_update_attachment_metadata()` when we're updating attachment data in
the database for any reason and ensure we have hooks in place for people
who need more efficient ways of knowing when subsize generation is
completed or files have changed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48451#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list