From c1af867a7c258eca503f971afd3b353ab0ff6a3a Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 3 Apr 2018 15:42:32 +0000 Subject: [PATCH] Meta: Simplify the delete all meta query in `delete_metadata()`. Merge of [42913] to the 4.6 branch. Built from https://develop.svn.wordpress.org/branches/4.6@42915 git-svn-id: http://core.svn.wordpress.org/branches/4.6@42745 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 8833d3e987..a252bc9abb 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -364,12 +364,11 @@ function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d return false; 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 AND meta_value = %s", $meta_key, $meta_value ) ); + } else { + $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) ); } - - $object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key ) ); } /**