[wp-trac] [WordPress Trac] #52603: Inconsistent doc for return value of wp_generate_attachment_metadata
WordPress Trac
noreply at wordpress.org
Mon Feb 22 19:08:25 UTC 2021
#52603: Inconsistent doc for return value of wp_generate_attachment_metadata
--------------------------+-----------------------------
Reporter: Chouby | Owner: SergeyBiryukov
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 5.8
Component: Media | Version: 2.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses: docs
--------------------------+-----------------------------
Changes (by SergeyBiryukov):
* owner: (none) => SergeyBiryukov
* status: new => reviewing
* milestone: Awaiting Review => 5.8
Comment:
Thanks for the patch!
It looks like `wp_generate_attachment_metadata()` can actually return
`false` for an audio or video attachment that doesn't exist in the local
filesystem, as previously noted in comment:5:ticket:25649.
Some history here:
* [23766] / #23673
* [25968] / #25649
* [35554] / #34599
Since that was never documented neither in the function nor in the
`wp_generate_attachment_metadata` filter, I think we have two options
here:
* Make sure the function indeed always returns an array, as the
`wp_generate_attachment_metadata` filter says.
* Document that it returns `false` for an audio or video attachment that
doesn't exist in the local filesystem.
For consistency with other functions like `wp_create_image_subsizes()`, I
think the first option would be preferable here, see
[attachment:"52603.2.diff"]. Looking at the
`wp_generate_attachment_metadata()` instances in core, we don't really
expect it to return anything other than an array.
P.S. To complicate things a bit further, `wp_read_image_metadata()` does
return `false` on failure, same as `wp_read_audio_metadata()` and
`wp_read_video_metadata()`, but that's probably not super relevant here.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52603#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list