[wp-trac] [WordPress Trac] #51730: Feature request: For update_metadata to differentiate failure from no update
WordPress Trac
noreply at wordpress.org
Mon Nov 9 12:11:35 UTC 2020
#51730: Feature request: For update_metadata to differentiate failure from no
update
-----------------------------+-----------------------------
Reporter: msea55 | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: administration |
-----------------------------+-----------------------------
The wordpress function update_metadata, (as well as update_post_meta, and
update_term_meta which call it) returns false on failure or if the value
passed to the function is the same as the one that is already in the
database. This behavior is documented by wordpress:
https://developer.wordpress.org/reference/functions/update_metadata/.
However, I would like to be able to differentiate the failure case from
the no update case. In my custom plugin I allow users to update post meta;
I want to show them a failure message if their update failed and nothing
if there was no update.
There is precedent for such a differentiation in wpdb::update which
returns 0 if no rows are updated and false on failure. I can use this
instead, but I would like the full functionality of update_metadata.
Is there a reason this differentiation is not made here? (either by
default or with a passed in parameter). If not, this is a feature request
to make that differentiation and return false on failure and 0 on no
update.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51730>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list