Opened 9 years ago
Last modified 9 years ago
#40012 new defect (bug)
Only add_metadata if no matching value
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 2.9 |
| Component: | Options, Meta APIs | Keywords: | 2nd-opinion |
| Focuses: | Cc: |
Description
add_metadata() has a $unique parameter, but it only looks for a unique meta_key for the given object ID. I have a need to add meta-data with the same meta_key but different values, and only if that meta_value isn't already present with the same key.
To do this now, requires:
- Getting all meta-data for the ID by
meta_key - Checking those array-values for my value
- Bailing if it's already present, or...
- Proceeding with
$uniqueset tofalse
It'd be lovely if add_metadata() either:
- Accepted strings like
key,valuefor the$uniqueparameter, to switch up the check - Added a second parameter for unique value in addition to a unique key
Attachments (1)
Change History (2)
Note: See
TracTickets for help on using
tickets.
Proof of concept. Needs testing with serialized data.