Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#11650 closed defect (bug) (fixed)

Unable to create empty value for postmeta

Reported by: dd32 Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9
Component: Administration Keywords: has-patch
Focuses: Cc:


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)

11650.dif (576 bytes) - added by dd32 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 @dd326 years ago

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"

comment:2 @mrmist6 years ago

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.

comment:4 @Denis-de-Bernardy6 years ago

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.)

comment:5 @dd326 years ago

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.

@dd326 years ago

comment:6 @dd326 years ago

  • 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())

comment:7 @rfair4046 years ago

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 @technosailor5 years ago

Patch tested and works.

comment:9 @dd325 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [14214]) Add descriptive error messages on Custom Fields updates attempting to set a empty Key or Value. Fixes #11650

Note: See TracTickets for help on using tickets.