Merge pull request woocommerce/woocommerce-admin#1497 from woocommerce/fix/initial-order-sync-stalling
Fix initial order sync stalling
This commit is contained in:
commit
432e7efaab
|
@ -672,12 +672,24 @@ class WC_Admin_Api_Init {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$next_job_schedule = null;
|
||||||
|
$blocking_job_hook = null;
|
||||||
|
|
||||||
if ( $blocking_jobs ) {
|
if ( $blocking_jobs ) {
|
||||||
$blocking_job = current( $blocking_jobs );
|
$blocking_job = current( $blocking_jobs );
|
||||||
$after_blocking_job = $blocking_job->get_schedule()->next()->getTimestamp() + 5;
|
$blocking_job_hook = $blocking_job->get_hook();
|
||||||
|
$next_job_schedule = $blocking_job->get_schedule()->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eliminate the false positive scenario where the blocking job is
|
||||||
|
// actually another queued dependent action awaiting the same prerequisite.
|
||||||
|
// Also, ensure that the next schedule is a DateTime (it can be null).
|
||||||
|
if (
|
||||||
|
is_a( $next_job_schedule, 'DateTime' ) &&
|
||||||
|
( self::QUEUE_DEPEDENT_ACTION !== $blocking_job_hook )
|
||||||
|
) {
|
||||||
self::queue()->schedule_single(
|
self::queue()->schedule_single(
|
||||||
$after_blocking_job,
|
$next_job_schedule->getTimestamp() + 5,
|
||||||
self::QUEUE_DEPEDENT_ACTION,
|
self::QUEUE_DEPEDENT_ACTION,
|
||||||
array( $action, $action_args, $prerequisite_action )
|
array( $action, $action_args, $prerequisite_action )
|
||||||
);
|
);
|
||||||
|
|
|
@ -319,7 +319,9 @@ class WC_Admin_Reports_Coupons_Data_Store extends WC_Admin_Reports_Data_Store im
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$order = wc_get_order( $order_id );
|
$order = wc_get_order( $order_id );
|
||||||
if ( ! $order ) {
|
|
||||||
|
// Skip `shop_order_refunds` when factoring stats on coupon usage.
|
||||||
|
if ( ! $order || 'shop_order' !== $order->get_type() ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,9 @@ class WC_Admin_Reports_Products_Data_Store extends WC_Admin_Reports_Data_Store i
|
||||||
array( '%d' )
|
array( '%d' )
|
||||||
); // WPCS: cache ok, DB call ok.
|
); // WPCS: cache ok, DB call ok.
|
||||||
|
|
||||||
|
// Deleting 0 items here isn't a problem, and we should force a successful return.
|
||||||
|
$result = ( 0 === $result ) ? 1 : $result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when product's reports are deleted.
|
* Fires when product's reports are deleted.
|
||||||
*
|
*
|
||||||
|
|
|
@ -258,7 +258,9 @@ class WC_Admin_Reports_Taxes_Data_Store extends WC_Admin_Reports_Data_Store impl
|
||||||
public static function sync_order_taxes( $order_id ) {
|
public static function sync_order_taxes( $order_id ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$order = wc_get_order( $order_id );
|
$order = wc_get_order( $order_id );
|
||||||
if ( ! $order ) {
|
|
||||||
|
// Skip `shop_order_refunds` when factoring stats on order tax.
|
||||||
|
if ( ! $order || 'shop_order' !== $order->get_type() ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue