Skip to content

Commit

Permalink
Sync: Ensure filtering orders by status when doing HPOS Checksums (#3…
Browse files Browse the repository at this point in the history
…9020)

* Make sure we filter by status when doing HPOS checksums

* Changelog

* Version bump

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/10557681423

Upstream-Ref: Automattic/jetpack@549db1f
  • Loading branch information
darssen authored and matticbot committed Aug 26, 2024
1 parent ebb7a37 commit aeb2e9c
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function get_objects_by_id( $object_type, $ids ) {
array(
'post__in' => $ids,
'type' => self::get_order_types_to_sync( true ),
'post_status' => $this->get_all_possible_order_status_keys(),
'post_status' => self::get_all_possible_order_status_keys(),
'limit' => -1,
)
);
Expand Down Expand Up @@ -301,7 +301,7 @@ private function filter_order_data( $order_object ) {
if ( '' === $filtered_order_data['status'] ) {
$filtered_order_data['status'] = 'pending';
}
$filtered_order_data['status'] = $this->get_wc_order_status_with_prefix( $filtered_order_data['status'] );
$filtered_order_data['status'] = self::get_wc_order_status_with_prefix( $filtered_order_data['status'] );

/**
* Filter the order data before syncing.
Expand All @@ -317,13 +317,13 @@ private function filter_order_data( $order_object ) {
/**
* Returns all possible order status keys, including 'auto-draft' and 'trash'.
*
* @access protected
* @access public
*
* @return array An array of all possible status keys, including 'auto-draft' and 'trash'.
*/
protected function get_all_possible_order_status_keys() {
public static function get_all_possible_order_status_keys() {
$order_statuses = array( 'auto-draft', 'trash' );
$wc_order_statuses = $this->wc_get_order_status_keys();
$wc_order_statuses = self::wc_get_order_status_keys();

return array_unique( array_merge( $wc_order_statuses, $order_statuses ) );
}
Expand All @@ -335,8 +335,8 @@ protected function get_all_possible_order_status_keys() {
*
* @return string The WC order status with the 'wc-' prefix if it's a valid order status, initial $status otherwise.
*/
protected function get_wc_order_status_with_prefix( string $status ) {
return in_array( 'wc-' . $status, $this->wc_get_order_status_keys(), true ) ? 'wc-' . $status : $status;
protected static function get_wc_order_status_with_prefix( string $status ) {
return in_array( 'wc-' . $status, self::wc_get_order_status_keys(), true ) ? 'wc-' . $status : $status;
}

/**
Expand All @@ -346,7 +346,7 @@ protected function get_wc_order_status_with_prefix( string $status ) {
*
* @return array Filtered order metadata.
*/
private function wc_get_order_status_keys() {
private static function wc_get_order_status_keys() {
$wc_order_statuses = array();
if ( function_exists( 'wc_get_order_statuses' ) ) {
$wc_order_statuses = array_keys( wc_get_order_statuses() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,14 @@ protected function get_default_tables() {
'checksum_fields' => array( 'date_updated_gmt', 'total_amount' ),
'checksum_text_fields' => array( 'type', 'status' ),
'filter_values' => array(
'type' => array(
'type' => array(
'operator' => 'IN',
'values' => WooCommerce_HPOS_Orders::get_order_types_to_sync( true ),
),
'status' => array(
'operator' => 'IN',
'values' => WooCommerce_HPOS_Orders::get_all_possible_order_status_keys(),
),
),
'is_table_enabled_callback' => 'Automattic\Jetpack\Sync\Replicastore\Table_Checksum::enable_woocommerce_hpos_tables',
),
Expand Down
60 changes: 30 additions & 30 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-a8c-mc-stats",
"reference": "4c01c63c8814ae430ae0f07b637fca2ab8e37525"
"reference": "08030911408770a3b92e3632ae1ddaced39d6891"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -134,7 +134,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-admin-ui",
"reference": "fb69260aefac17a52acbff2e66eed15df5a006ec"
"reference": "2bc2d2c365c12de4c82f70a4a614010ebb450158"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -199,7 +199,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-assets",
"reference": "d1d74c143657d835eaa670ad6ea8c6a4435420b2"
"reference": "9d52ab7a8763637847f04fad9d3d5460f850ac8b"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -268,7 +268,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-blaze",
"reference": "768ba32d9b8c3cda9d32802b7c18baf0594930f2"
"reference": "fb98f8d35047e76908bd2cf908dbe6aa3fba5932"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -349,7 +349,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-blocks",
"reference": "01e982c80f6209189250aeba188bc1527e78df7f"
"reference": "d31200598f5005ec625e50d8e79ee958c038958e"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -411,7 +411,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-calypsoify",
"reference": "0c4a95560788e82b8b078c14ef0b5f585ab67ae4"
"reference": "613cf8ba1eb094362468d2e12aed98f41f22b29c"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -476,7 +476,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-classic-theme-helper",
"reference": "b8e0e952930f0eda74c76dcadee47551a38d270f"
"reference": "2dd05d4cb21d1c4df96bb124277bf72ff9fdea7e"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -547,7 +547,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-compat",
"reference": "c56a45eda30e5127f226b0b7507480fe625e4e1b"
"reference": "affffba3846194d330df326376c3b7ed5137c50a"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -587,7 +587,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-config",
"reference": "92750d6cd5ffed74c8e9896bbe209083467b6b53"
"reference": "2b1badbcaee9cb270f8218fd9e9326114e427266"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -662,7 +662,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-connection",
"reference": "a10fcae7ec1dabdb68aeed46dd1043c17556ae08"
"reference": "09899c8e3fb1fdd21fdf5aa0fe5f028aa9934b41"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.2",
Expand Down Expand Up @@ -749,7 +749,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-constants",
"reference": "cedacf7ec55e5ce5c7856a92e5c0899c2585026e"
"reference": "f3b462c79a9a7c4b772ebc3e73e9761d4a30046f"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -803,7 +803,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "6f91ccdd53e57241bac92407f446ef3b14e1bf35"
"reference": "360023b727a78e0ab78bc45572925ae4005ec4f3"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -856,7 +856,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-google-analytics",
"reference": "a055768d3f617225f91ced2406e8353c0e263437"
"reference": "264ab8697a4843b1607e4b2740504213b5d07858"
},
"require": {
"automattic/jetpack-status": "^3.3.4",
Expand Down Expand Up @@ -927,7 +927,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-ip",
"reference": "445e70edc2e92ce05f839538652ae381014793a3"
"reference": "d52c17c1799f8356b76fbed4a62b8ae170d06e92"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -985,7 +985,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-jitm",
"reference": "45dbd1f3d32627d31dabf8bf91726e1a59f0039f"
"reference": "ac7762004a6d452277596c83b51b6faab78721d1"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.2",
Expand Down Expand Up @@ -1060,7 +1060,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-logo",
"reference": "2127358a0be88f45bd872b38d716aba943db84b2"
"reference": "64e628ffade35df6759dbd57f75f5999adfe8c79"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1113,7 +1113,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-masterbar",
"reference": "6c7a6ceac6cf0c47443f1ec9822be09f9db0196e"
"reference": "01f5e9e719bdc92c4bec86ecf70354c0d8b48a0a"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -1195,7 +1195,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom",
"reference": "dd2d0c0ed884a2f63d09b8261799393ece2c1bd5"
"reference": "0f98bf0e4875ba4ce0785755fe88d73ab37d90d9"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -1278,7 +1278,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-password-checker",
"reference": "9736029e62436a9eda03ec6f4837cc58bc076ef5"
"reference": "53e35cdf7037a7530fbb264f0b2ed55927dc8478"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1339,7 +1339,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plans",
"reference": "7b2c3ba79bebc6955fa74759f40e0dcea9e12988"
"reference": "32df9f72faa52efd3e75cb840ce5aeb7420abd28"
},
"require": {
"automattic/jetpack-connection": "^2.12.4",
Expand Down Expand Up @@ -1407,7 +1407,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-post-list",
"reference": "3b9c14545a8f4b3dbc2a7777db92d561bb81c4e1"
"reference": "62fe90e08cd8d9b5c3c1d99b58a114ec6443c60d"
},
"require": {
"automattic/jetpack-assets": "^2.3.4",
Expand Down Expand Up @@ -1472,7 +1472,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-redirect",
"reference": "37ebf5c89194e1bd72840e3fdcb9845010b838c4"
"reference": "ec540b97d32e89cda65103c79e58d09bd9b50fe5"
},
"require": {
"automattic/jetpack-status": "^3.3.4",
Expand Down Expand Up @@ -1527,7 +1527,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-roles",
"reference": "116bbb8527502c4c693a26c0dc6730200ae03530"
"reference": "ba9932e0e2c029afa2178f01bb0e226cfb6345b5"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1581,7 +1581,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-stats",
"reference": "8835d5900fc42cde99df028f0188e8078bef4da0"
"reference": "9d10a06571d1120b50deee3536d4bb0acd54a715"
},
"require": {
"automattic/jetpack-connection": "^2.12.4",
Expand Down Expand Up @@ -1648,7 +1648,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-stats-admin",
"reference": "8fe6100abc1f8ec8a55c1a24384be35329ba4e2b"
"reference": "e42758f0f1676ffe2af37d36ba18549024219909"
},
"require": {
"automattic/jetpack-connection": "^2.12.4",
Expand Down Expand Up @@ -1721,7 +1721,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-status",
"reference": "22431e2686d60be781a8b1c73dba7d858be5517f"
"reference": "bde41b9cf22046634ff598618db2f72b0ec19601"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -1780,12 +1780,12 @@
},
{
"name": "automattic/jetpack-sync",
"version": "3.8.0-alpha.1724664985",
"version_normalized": "3.8.0.0-alpha1724664985",
"version": "3.8.0-alpha.1724666339",
"version_normalized": "3.8.0.0-alpha1724666339",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-sync",
"reference": "88816be65a64c784f6404b38520ef9dfa72837f9"
"reference": "3df106fbc4d061a1a6118f1d8efc5f5835e5e9bd"
},
"require": {
"automattic/jetpack-connection": "^2.12.4",
Expand Down Expand Up @@ -1863,7 +1863,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/scheduled-updates",
"reference": "c19f89fdc30660e337cad59ab91d0bcc0ee2cc7c"
"reference": "9fce511ee8014ccdddedce009fcf9fdb49d958c5"
},
"require": {
"automattic/jetpack-connection": "^2.12.4",
Expand Down
Loading

0 comments on commit aeb2e9c

Please sign in to comment.