[wp-trac] [WordPress Trac] #34848: Add support for updating post meta in bulk
WordPress Trac
noreply at wordpress.org
Thu Apr 14 17:35:05 UTC 2016
#34848: Add support for updating post meta in bulk
------------------------------------------+-----------------------------
Reporter: patrickgarman | Owner: chriscct7
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: Options, Meta APIs | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: performance
------------------------------------------+-----------------------------
Comment (by boonebgorges):
Currently, if you pass an array to `$meta_key`, lots of stuff will break.
For example, `$wpdb->prepare( "SELECT COUNT(*) FROM $table WHERE meta_key
= %s AND $column = %d", $meta_key, $object_id )`. So I don't think there
are many backward compatibility concerns, since that syntax currently will
not work in any meaningful way.
A couple other thoughts about the approach, since I'm back commenting on
this ticket :)
- Can we use the `$wpdb` insert/update/delete handlers instead of building
SQL?
- Why does `update` not get separate treatment? The `add` vs `update`
behavior is pretty established for single metadata, so it probably makes
sense to reproduce it here. This includes things like action/filter names
and `add` fallback for non-existing meta in `update`.
- Return values are tricky here. `add_metadata()` returns the row ID on
success, while `update` returns a boolean. Is it worth trying to reproduce
this? What would this look like if `add` fell back on `update` for some,
but not all, of the keys passed to the function?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34848#comment:16>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list