Merge pull request #17646 from james-allan/fix_add_indexes_db_warning

Fix db warnings when using the "Add Order Indexes" tool
This commit is contained in:
Mike Jolley 2017-11-10 11:55:36 +00:00 committed by GitHub
commit a164ff3db5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -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;