From c91698cde3bf77155f98af86aa91a6d35b73e5b8 Mon Sep 17 00:00:00 2001 From: James Allan Date: Fri, 10 Nov 2017 16:21:28 +1000 Subject: [PATCH] Fix db warnings when using the "Add Order Indexes" tool --- .../class-wc-rest-system-status-tools-controller.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/api/class-wc-rest-system-status-tools-controller.php b/includes/api/class-wc-rest-system-status-tools-controller.php index c84513df048..ed63e5cb957 100644 --- a/includes/api/class-wc-rest-system-status-tools-controller.php +++ b/includes/api/class-wc-rest-system-status-tools-controller.php @@ -406,15 +406,15 @@ class WC_REST_System_Status_Tools_Controller extends WC_REST_Controller { * that don't have address indexes yet. */ $sql = "INSERT INTO {$wpdb->postmeta}( post_id, meta_key, meta_value ) - SELECT post_id, '%1\$s', GROUP_CONCAT( meta_value SEPARATOR ' ' ) + SELECT post_id, '%s', GROUP_CONCAT( meta_value SEPARATOR ' ' ) FROM {$wpdb->postmeta} - WHERE meta_key IN ( '%2\$s', '%3\$s' ) + WHERE meta_key IN ( '%s', '%s' ) AND post_id IN ( SELECT DISTINCT post_id FROM {$wpdb->postmeta} - WHERE post_id NOT IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%1\$s' ) - AND post_id IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%3\$s' ) ) + WHERE post_id NOT IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%s' ) + AND post_id IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='%s' ) ) GROUP BY post_id"; - $rows = $wpdb->query( $wpdb->prepare( $sql, '_billing_address_index', '_billing_first_name', '_billing_last_name' ) ); - $rows += $wpdb->query( $wpdb->prepare( $sql, '_shipping_address_index', '_shipping_first_name', '_shipping_last_name' ) ); + $rows = $wpdb->query( $wpdb->prepare( $sql, '_billing_address_index', '_billing_first_name', '_billing_last_name', '_billing_address_index', '_billing_last_name' ) ); + $rows += $wpdb->query( $wpdb->prepare( $sql, '_shipping_address_index', '_shipping_first_name', '_shipping_last_name', '_shipping_address_index', '_shipping_last_name') ); $message = sprintf( __( '%d indexes added', 'woocommerce' ), $rows ); break;