In `delete_metadata()`, only invalidate cache for affected objects.

The `$delete_all` flag in `delete_metadata()` triggers cache invalidation for
multiple objects. Previously, invalidation took place for all objects matching
the `$meta_key` parameter, regardless of whether `$meta_value` was also set.
This resulted in overly aggressive invalidation.

Props rahal.aboulfeth.
Fixes #35797.
Built from https://develop.svn.wordpress.org/trunk@36511


git-svn-id: http://core.svn.wordpress.org/trunk@36478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-02-12 02:47:26 +00:00
parent 2bfc0f5218
commit 3e9c88d75a
2 changed files with 9 additions and 3 deletions

View File

@ -363,8 +363,14 @@ function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d
if ( !count( $meta_ids ) )
return false;
if ( $delete_all )
$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) );
if ( $delete_all ) {
$value_clause = '';
if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) {
$value_clause = $wpdb->prepare( " AND meta_value = %s", $meta_value );
}
$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key ) );
}
/**
* Fires immediately before deleting metadata of a specific type.

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36510';
$wp_version = '4.5-alpha-36511';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.