Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#11650 closed defect (bug) (fixed)

Unable to create empty value for postmeta

Reported by: dd32's profile 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 14 years ago.

Download all attachments as: .zip

Change History (10)

#1 @dd32
14 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"

#2 @mrmist
14 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.

#4 @Denis-de-Bernardy
14 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.)

#5 @dd32
14 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.

14 years ago

#6 @dd32
14 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())

#7 @rfair404
14 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.

#8 @technosailor
14 years ago

Patch tested and works.

#9 @dd32
14 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.