Opened 3 years ago

Closed 3 years ago

#11650 closed defect (bug) (fixed)

Unable to create empty value for postmeta

Reported by: dd32 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)

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

Download all attachments as: .zip

Change History (10)

comment:1   dd323 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"

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.

Related #7541 #10254

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

dd323 years ago

comment:6   dd323 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())

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.

Patch tested and works.

comment:9   dd323 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.