[wp-trac] [WordPress Trac] #24933: update_metadata() returns true even if meta value not updated
WordPress Trac
noreply at wordpress.org
Fri Aug 2 20:43:11 UTC 2013
#24933: update_metadata() returns true even if meta value not updated
-------------------------+-----------------------------
Reporter: jdgrimes | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.6
Severity: normal | Keywords:
-------------------------+-----------------------------
When `update_metadata()` updates a meta value with the `$prev_value`
parameter set, the return will be `true` regardless of whether any rows
were affected.
This makes it difficult to use the metadata API in cases in which a race
condition should be avoided. For example, we cannot reliably increment a
meta value. If we leave `$prev_value` empty, any intermediate changes will
be overridden; if we set it and the value has changed, the update will
silently fail (`update_metadata()` will still return `true`).
This is inconsistent with `update_option()`, which returns `true` only if
the number of rows affected is greater than `0`.
In short, this behavior makes this function pretty much useless in cases
where a race condition needs to be avoided.
My request a way of detecting whether any rows were actually affected or
not when this function is called.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24933>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list