Merge pull request woocommerce/woocommerce-admin#1497 from woocommerce/fix/initial-order-sync-stalling

Fix initial order sync stalling
This commit is contained in:
Jeff Stieler 2019-02-07 22:04:50 -08:00 committed by GitHub
commit 432e7efaab
4 changed files with 25 additions and 6 deletions

View File

@ -672,12 +672,24 @@ class WC_Admin_Api_Init {
)
);
if ( $blocking_jobs ) {
$blocking_job = current( $blocking_jobs );
$after_blocking_job = $blocking_job->get_schedule()->next()->getTimestamp() + 5;
$next_job_schedule = null;
$blocking_job_hook = null;
if ( $blocking_jobs ) {
$blocking_job = current( $blocking_jobs );
$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(
$after_blocking_job,
$next_job_schedule->getTimestamp() + 5,
self::QUEUE_DEPEDENT_ACTION,
array( $action, $action_args, $prerequisite_action )
);

View File

@ -319,7 +319,9 @@ class WC_Admin_Reports_Coupons_Data_Store extends WC_Admin_Reports_Data_Store im
global $wpdb;
$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;
}

View File

@ -381,6 +381,9 @@ class WC_Admin_Reports_Products_Data_Store extends WC_Admin_Reports_Data_Store i
array( '%d' )
); // 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.
*

View File

@ -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 ) {
global $wpdb;
$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;
}