Opened 14 years ago
Closed 12 years ago
#16391 closed enhancement (fixed)
Don't add empty "_wp_attachment_metadata" on non-image media files
Reported by: | Caspie | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | minor | Version: | 3.0.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
I'm currently working on a community project where there are a lot of front-end file uploads. I've noticed that when you upload a non-image file, an empty _wp_attachment_metadata is added to the postmeta table. Just did a quick patch to check the $data in wp_update_attachment_metadata function. And since $data comes always as an array from wp_generate_attachment_metadata, we do not update if it is an empty array.
Attachments (3)
Change History (15)
#2
@
14 years ago
- Milestone changed from Awaiting Review to Future Release
- Severity changed from normal to minor
- Type changed from defect (bug) to enhancement
#3
in reply to:
↑ 1
@
14 years ago
Replying to scribu:
You should use
!empty()
instead ofcount()
.
thx! for better performance I guess?
#5
@
12 years ago
- Keywords needs-refresh added
- Milestone changed from Future Release to 3.5
We can actually just say if ( $data )
.
#8
@
12 years ago
- Keywords needs-patch added; has-patch commit removed
- Type changed from defect (bug) to enhancement
When updating an attachment with empty file or data after it previously had a meta value for _wp_attached_file or _wp_attachment_metadata, the data would not get cleared.
The options are either not applying this patch, or doing if ( $date ) update; else delete;
I no longer consider this a pure bug.
You should use
!empty()
instead ofcount()
.