This commit is contained in:
Albert Juhé Lluveras 2019-09-13 18:39:51 +02:00 committed by GitHub
parent f095466442
commit 3406bd85e0
2 changed files with 9 additions and 9 deletions

View File

@ -27,7 +27,7 @@ class ReportsSync {
/** /**
* Action hook for queuing an action after another is complete. * Action hook for queuing an action after another is complete.
*/ */
const QUEUE_DEPEDENT_ACTION = 'wc-admin_queue_dependent_action'; const QUEUE_DEPENDENT_ACTION = 'wc-admin_queue_dependent_action';
/** /**
* Action hook for importing a batch of customers. * Action hook for importing a batch of customers.
@ -118,7 +118,7 @@ class ReportsSync {
// Initialize scheduled action handlers. // Initialize scheduled action handlers.
add_action( self::QUEUE_BATCH_ACTION, array( __CLASS__, 'queue_batches' ), 10, 4 ); add_action( self::QUEUE_BATCH_ACTION, array( __CLASS__, 'queue_batches' ), 10, 4 );
add_action( self::QUEUE_DEPEDENT_ACTION, array( __CLASS__, 'queue_dependent_action' ), 10, 3 ); add_action( self::QUEUE_DEPENDENT_ACTION, array( __CLASS__, 'queue_dependent_action' ), 10, 3 );
add_action( self::CUSTOMERS_IMPORT_BATCH_ACTION, array( __CLASS__, 'customer_lookup_import_batch' ), 10, 3 ); add_action( self::CUSTOMERS_IMPORT_BATCH_ACTION, array( __CLASS__, 'customer_lookup_import_batch' ), 10, 3 );
add_action( self::CUSTOMERS_DELETE_BATCH_INIT, array( __CLASS__, 'customer_lookup_delete_batch_init' ) ); add_action( self::CUSTOMERS_DELETE_BATCH_INIT, array( __CLASS__, 'customer_lookup_delete_batch_init' ) );
add_action( self::CUSTOMERS_DELETE_BATCH_ACTION, array( __CLASS__, 'customer_lookup_delete_batch' ) ); add_action( self::CUSTOMERS_DELETE_BATCH_ACTION, array( __CLASS__, 'customer_lookup_delete_batch' ) );
@ -226,7 +226,7 @@ class ReportsSync {
// If we're using our data store, call our bespoke deletion method. // If we're using our data store, call our bespoke deletion method.
$action_types = array( $action_types = array(
self::QUEUE_BATCH_ACTION, self::QUEUE_BATCH_ACTION,
self::QUEUE_DEPEDENT_ACTION, self::QUEUE_DEPENDENT_ACTION,
self::CUSTOMERS_IMPORT_BATCH_ACTION, self::CUSTOMERS_IMPORT_BATCH_ACTION,
self::CUSTOMERS_DELETE_BATCH_INIT, self::CUSTOMERS_DELETE_BATCH_INIT,
self::CUSTOMERS_DELETE_BATCH_ACTION, self::CUSTOMERS_DELETE_BATCH_ACTION,
@ -305,7 +305,7 @@ class ReportsSync {
if ( if (
( self::SINGLE_ORDER_IMPORT_ACTION === $existing_job->get_hook() ) || ( self::SINGLE_ORDER_IMPORT_ACTION === $existing_job->get_hook() ) ||
( (
self::QUEUE_DEPEDENT_ACTION === $existing_job->get_hook() && self::QUEUE_DEPENDENT_ACTION === $existing_job->get_hook() &&
in_array( self::SINGLE_ORDER_IMPORT_ACTION, $existing_job->get_args(), true ) in_array( self::SINGLE_ORDER_IMPORT_ACTION, $existing_job->get_args(), true )
) )
) { ) {
@ -602,11 +602,11 @@ class ReportsSync {
// Also, ensure that the next schedule is a DateTime (it can be null). // Also, ensure that the next schedule is a DateTime (it can be null).
if ( if (
is_a( $next_job_schedule, 'DateTime' ) && is_a( $next_job_schedule, 'DateTime' ) &&
( self::QUEUE_DEPEDENT_ACTION !== $blocking_job_hook ) ( self::QUEUE_DEPENDENT_ACTION !== $blocking_job_hook )
) { ) {
self::queue()->schedule_single( self::queue()->schedule_single(
$next_job_schedule->getTimestamp() + 5, $next_job_schedule->getTimestamp() + 5,
self::QUEUE_DEPEDENT_ACTION, self::QUEUE_DEPENDENT_ACTION,
array( $action, $action_args, $prerequisite_action ), array( $action, $action_args, $prerequisite_action ),
self::QUEUE_GROUP self::QUEUE_GROUP
); );

View File

@ -154,7 +154,7 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
1, 1,
ReportsSync::queue()->search( ReportsSync::queue()->search(
array( array(
'hook' => ReportsSync::QUEUE_DEPEDENT_ACTION, 'hook' => ReportsSync::QUEUE_DEPENDENT_ACTION,
'args' => array( 'dependent_action', array(), 'blocking_job' ), 'args' => array( 'dependent_action', array(), 'blocking_job' ),
) )
) )
@ -175,7 +175,7 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
$this->assertEmpty( $this->assertEmpty(
ReportsSync::queue()->search( ReportsSync::queue()->search(
array( array(
'hook' => ReportsSync::QUEUE_DEPEDENT_ACTION, 'hook' => ReportsSync::QUEUE_DEPENDENT_ACTION,
'args' => array( 'another_dependent_action', array(), 'nonexistant_blocking_job' ), 'args' => array( 'another_dependent_action', array(), 'nonexistant_blocking_job' ),
) )
) )
@ -183,6 +183,6 @@ class WC_Tests_Reports_Regenerate_Batching extends WC_REST_Unit_Test_Case {
// clean up. // clean up.
ReportsSync::queue()->cancel_all( 'another_dependent_action' ); ReportsSync::queue()->cancel_all( 'another_dependent_action' );
ReportsSync::queue()->cancel_all( ReportsSync::QUEUE_DEPEDENT_ACTION ); ReportsSync::queue()->cancel_all( ReportsSync::QUEUE_DEPENDENT_ACTION );
} }
} }