Opened 3 years ago
Closed 3 years ago
#11650 closed defect (bug) (fixed)
Unable to create empty value for postmeta
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Administration | Version: | 2.9 |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
As posted by John on wp-testers, Post meta doesnt allow for a blank meta value, and simply gives an error of "An unidentified error has occurred." when attempting to update the value.
Comfirmed on 3.0
Attachments (1)
Change History (10)
This seems like a regression, or at least the entire issue was not fixed in the previous bug for custom fields. The unidentified error used to appear when adding a new custom field with no value - that now displays a proper error - now it seems to appear when setting an existing one to a blank.
I can't recall to have ever managed to store an empty string as a postmeta. zero works however (or worked, anyway).
(for user meta, only an empty array works. everything else will just get ignored.)
I somewhat dont think a empty value has ever been allowed.
In this case, I think the error condition simply needs to be raised on the ajax call.
- Keywords has-patch added; needs-patch removed
attachment 11650.dif added
- Adds a Error if you attempt to update meta to a empty value.
- non-empty string is fine
- 0 is fine
- Zero length string is not
- Nor is a whitespace-only string (Meta refuses to add it, which is the reason for the trim())
If you try to add a custom field with a valid key value but whitespace in the meta key name itself (Enter New > put spaces in the Name field > put valid input into value field)
Then click Add Custom field Error message is still "Please provide a custom field value." should read ... a custom field name.
comment:8
technosailor — 3 years ago
Patch tested and works.

If a blank meta value is not allowed, As i suspect, Then the error message either needs to be changed to reflect that, Or updating with an empty value should delete it - In that case, a javascript warning "Warning: Updating this meta value to blank will delete this custom field"