[wp-trac] [WordPress Trac] #51730: update_metadata function: differentiate failure from no update (was: Feature request: For update_metadata to differentiate failure from no update)
WordPress Trac
noreply at wordpress.org
Tue Nov 10 00:50:13 UTC 2020
#51730: update_metadata function: differentiate failure from no update
--------------------------------+------------------------------
Reporter: msea55 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: | Focuses: administration
--------------------------------+------------------------------
Changes (by sabernhardt):
* type: feature request => enhancement
* component: General => Options, Meta APIs
Old description:
> 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.
New description:
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#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list