Skip to content

Commit 912f5e4

Browse files
darssenmatticbot
authored andcommitted
Sync: Ensure filtering orders by status when doing HPOS Checksums (#39020)
* 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
1 parent 11af6ce commit 912f5e4

File tree

6 files changed

+101
-94
lines changed

6 files changed

+101
-94
lines changed

composer.lock

Lines changed: 29 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/automattic/jetpack-sync/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ This is an alpha version! The changes listed here are not final.
1212
### Changed
1313
- Sync: Updated allowed order types in HPOS Module
1414

15+
### Fixed
16+
- Sync: Ensure filtering orders by status when doing HPOS Checksums
17+
1518
## [3.7.1] - 2024-08-23
1619
### Changed
1720
- Updated package dependencies. [#39004]

vendor/automattic/jetpack-sync/src/modules/class-woocommerce-hpos-orders.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function get_objects_by_id( $object_type, $ids ) {
166166
array(
167167
'post__in' => $ids,
168168
'type' => self::get_order_types_to_sync( true ),
169-
'post_status' => $this->get_all_possible_order_status_keys(),
169+
'post_status' => self::get_all_possible_order_status_keys(),
170170
'limit' => -1,
171171
)
172172
);
@@ -301,7 +301,7 @@ private function filter_order_data( $order_object ) {
301301
if ( '' === $filtered_order_data['status'] ) {
302302
$filtered_order_data['status'] = 'pending';
303303
}
304-
$filtered_order_data['status'] = $this->get_wc_order_status_with_prefix( $filtered_order_data['status'] );
304+
$filtered_order_data['status'] = self::get_wc_order_status_with_prefix( $filtered_order_data['status'] );
305305

306306
/**
307307
* Filter the order data before syncing.
@@ -317,13 +317,13 @@ private function filter_order_data( $order_object ) {
317317
/**
318318
* Returns all possible order status keys, including 'auto-draft' and 'trash'.
319319
*
320-
* @access protected
320+
* @access public
321321
*
322322
* @return array An array of all possible status keys, including 'auto-draft' and 'trash'.
323323
*/
324-
protected function get_all_possible_order_status_keys() {
324+
public static function get_all_possible_order_status_keys() {
325325
$order_statuses = array( 'auto-draft', 'trash' );
326-
$wc_order_statuses = $this->wc_get_order_status_keys();
326+
$wc_order_statuses = self::wc_get_order_status_keys();
327327

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

342342
/**
@@ -346,7 +346,7 @@ protected function get_wc_order_status_with_prefix( string $status ) {
346346
*
347347
* @return array Filtered order metadata.
348348
*/
349-
private function wc_get_order_status_keys() {
349+
private static function wc_get_order_status_keys() {
350350
$wc_order_statuses = array();
351351
if ( function_exists( 'wc_get_order_statuses' ) ) {
352352
$wc_order_statuses = array_keys( wc_get_order_statuses() );

vendor/automattic/jetpack-sync/src/replicastore/class-table-checksum.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ protected function get_default_tables() {
315315
'checksum_fields' => array( 'date_updated_gmt', 'total_amount' ),
316316
'checksum_text_fields' => array( 'type', 'status' ),
317317
'filter_values' => array(
318-
'type' => array(
318+
'type' => array(
319319
'operator' => 'IN',
320320
'values' => WooCommerce_HPOS_Orders::get_order_types_to_sync( true ),
321321
),
322+
'status' => array(
323+
'operator' => 'IN',
324+
'values' => WooCommerce_HPOS_Orders::get_all_possible_order_status_keys(),
325+
),
322326
),
323327
'is_table_enabled_callback' => 'Automattic\Jetpack\Sync\Replicastore\Table_Checksum::enable_woocommerce_hpos_tables',
324328
),

0 commit comments

Comments
 (0)