Opened 16 years ago
Closed 14 years ago
#16391 closed enhancement (fixed)
Don't add empty "_wp_attachment_metadata" on non-image media files
| Reported by: | Caspie | Owned by: | ryan |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | 3.0.1 |
| Severity: | minor | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
16 years ago
- Milestone Awaiting Review → Future Release
- Severity normal → minor
- Type defect (bug) → enhancement
#3
in reply to: ↑ 1
@
16 years ago
Replying to scribu:
You should use
!empty()instead ofcount().
thx! for better performance I guess?
#5
@
14 years ago
- Keywords needs-refresh added
- Milestone Future Release → 3.5
We can actually just say if ( $data ).
#8
@
14 years ago
- Keywords needs-patch added; has-patch commit removed
- Type defect (bug) → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
You should use
!empty()instead ofcount().