update_metadata() returns true even if meta value not updated
|Reported by:||jdgrimes||Owned by:||nacin|
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.
Change History (11)
comment:3 @leewillis77 — 21 months ago
- Cc junk@… added
- Keywords has-patch added
- Type changed from enhancement to defect (bug)
- Milestone changed from Awaiting Review to 3.7
- Owner set to nacin
- Status changed from new to accepted