From ccf10f6ab279902f1ce748df63cee1f769835f26 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 16 Apr 2018 15:04:57 -0300 Subject: [PATCH] Punt to WC version 3.5.0 --- .../class-wc-admin-list-table-orders.php | 3 ++- includes/class-wc-install.php | 4 +++- .../class-wc-order-data-store-cpt.php | 4 ++-- includes/wc-update-functions.php | 18 +++++++++--------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/includes/admin/list-tables/class-wc-admin-list-table-orders.php b/includes/admin/list-tables/class-wc-admin-list-table-orders.php index 0786d083098..463a0b435fd 100644 --- a/includes/admin/list-tables/class-wc-admin-list-table-orders.php +++ b/includes/admin/list-tables/class-wc-admin-list-table-orders.php @@ -751,7 +751,8 @@ class WC_Admin_List_Table_Orders extends WC_Admin_List_Table { if ( ! empty( $_GET['_customer_user'] ) ) { // WPCS: input var ok. $customer_id = (int) $_GET['_customer_user']; // WPCS: input var ok, sanitization ok. - if ( version_compare( get_option( 'woocommerce_db_version' ), '3.4.0', '>=' ) ) { + // On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table. + if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) { $query_vars['author'] = $customer_id; } else { // @codingStandardsIgnoreStart diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index e73b9571c79..e985b82bce4 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -100,10 +100,12 @@ class WC_Install { 'wc_update_330_db_version', ), '3.4.0' => array( - 'wc_update_340_order_customer_id', 'wc_update_340_irish_states', 'wc_update_340_db_version', ), + '3.5.0' => array( + 'wc_update_350_order_customer_id', + ), ); /** diff --git a/includes/data-stores/class-wc-order-data-store-cpt.php b/includes/data-stores/class-wc-order-data-store-cpt.php index 1ebb2b42e2f..02b68b44bb7 100644 --- a/includes/data-stores/class-wc-order-data-store-cpt.php +++ b/includes/data-stores/class-wc-order-data-store-cpt.php @@ -107,8 +107,8 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement $date_paid = get_post_meta( $id, '_paid_date', true ); } - // Make sure post_author is used only after WC 3.4.0 DB upgrade routine is executed. - if ( version_compare( get_option( 'woocommerce_db_version' ), '3.4.0', '>=' ) ) { + // On WC 3.5.0 the ID of the user that placed the order was moved from the post meta _customer_user to the post_author field in the wp_posts table. + if ( version_compare( get_option( 'woocommerce_db_version' ), '3.5.0', '>=' ) ) { $customer_id = $post_object->post_author; } else { $customer_id = get_post_meta( $id, '_customer_user', true ); diff --git a/includes/wc-update-functions.php b/includes/wc-update-functions.php index 1e1b849f0bb..e65d280db17 100644 --- a/includes/wc-update-functions.php +++ b/includes/wc-update-functions.php @@ -1678,15 +1678,22 @@ function wc_update_340_irish_states() { } } +/** + * Update DB Version. + */ +function wc_update_340_db_version() { + WC_Install::update_db_version( '3.4.0' ); +} + /** * Copy order customer_id from post meta to post_author and set post_author to 0 for refunds. * * @param WC_Background_Updater $updater Background updater instance. */ -function wc_update_340_order_customer_id( $updater ) { +function wc_update_350_order_customer_id( $updater ) { global $wpdb; - $post_types = (array) apply_filters( 'woocommerce_update_340_order_customer_id_post_types', array( 'shop_order' ) ); + $post_types = (array) apply_filters( 'woocommerce_update_350_order_customer_id_post_types', array( 'shop_order' ) ); $post_types_placeholders = implode( ', ', array_fill( 0, count( $post_types ), '%s' ) ); $admin_orders_sql = ''; @@ -1761,10 +1768,3 @@ function wc_update_340_order_customer_id( $updater ) { } } } - -/** - * Update DB Version. - */ -function wc_update_340_db_version() { - WC_Install::update_db_version( '3.4.0' ); -}