From 278641ebbc5b3421f8a1ba7048ad2feec8659e01 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Tue, 3 Apr 2018 15:40:58 +0000 Subject: [PATCH] Meta: Simplify the delete all meta query in `delete_metadata()`. Merge of [42913] to the 4.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@42914 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/meta.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index cfb9d95a9e..cd3cc74606 100644 --- a/src/wp-includes/meta.php +++ b/src/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 ) ); } /**