Skip to content

Commit

Permalink
Merge pull request #1131 from crstauf/phpcs/ActionScheduler_WPCLI_Que…
Browse files Browse the repository at this point in the history
…ueRunner.php

PHPCS: `classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php`
  • Loading branch information
barryhughes authored Oct 24, 2024
2 parents 9373a0b + 4990a5d commit 23f5aa8
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions classes/WP_CLI/ActionScheduler_WPCLI_QueueRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@
*/
class ActionScheduler_WPCLI_QueueRunner extends ActionScheduler_Abstract_QueueRunner {

/** @var array */
/**
* Claimed actions.
*
* @var array
*/
protected $actions;

/** @var ActionScheduler_ActionClaim */
/**
* ActionScheduler_ActionClaim instance.
*
* @var ActionScheduler_ActionClaim
*/
protected $claim;

/** @var \cli\progress\Bar */
/**
* Progress bar instance.
*
* @var \cli\progress\Bar
*/
protected $progress_bar;

/**
Expand All @@ -39,8 +51,6 @@ public function __construct( ActionScheduler_Store $store = null, ActionSchedule
/**
* Set up the Queue before processing.
*
* @author Jeremy Pry
*
* @param int $batch_size The batch size to process.
* @param array $hooks The hooks being used to filter the actions claimed in this batch.
* @param string $group The group of actions to claim with this batch.
Expand Down Expand Up @@ -72,8 +82,6 @@ public function setup( $batch_size, $hooks = array(), $group = '', $force = fals

/**
* Add our hooks to the appropriate actions.
*
* @author Jeremy Pry
*/
protected function add_hooks() {
add_action( 'action_scheduler_before_execute', array( $this, 'before_execute' ) );
Expand All @@ -83,8 +91,6 @@ protected function add_hooks() {

/**
* Set up the WP CLI progress bar.
*
* @author Jeremy Pry
*/
protected function setup_progress_bar() {
$count = count( $this->actions );
Expand All @@ -98,8 +104,6 @@ protected function setup_progress_bar() {
/**
* Process actions in the queue.
*
* @author Jeremy Pry
*
* @param string $context Optional runner context. Default 'WP CLI'.
*
* @return int The number of actions processed.
Expand All @@ -109,7 +113,7 @@ public function run( $context = 'WP CLI' ) {
$this->setup_progress_bar();
foreach ( $this->actions as $action_id ) {
// Error if we lost the claim.
if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ) ) ) {
if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $this->claim->get_id() ), true ) ) {
WP_CLI::warning( __( 'The claim has been lost. Aborting current batch.', 'action-scheduler' ) );
break;
}
Expand All @@ -129,8 +133,6 @@ public function run( $context = 'WP CLI' ) {
/**
* Handle WP CLI message when the action is starting.
*
* @author Jeremy Pry
*
* @param int $action_id Action ID.
*/
public function before_execute( $action_id ) {
Expand All @@ -141,8 +143,6 @@ public function before_execute( $action_id ) {
/**
* Handle WP CLI message when the action has completed.
*
* @author Jeremy Pry
*
* @param int $action_id ActionID.
* @param null|ActionScheduler_Action $action The instance of the action. Default to null for backward compatibility.
*/
Expand All @@ -158,8 +158,6 @@ public function after_execute( $action_id, $action = null ) {
/**
* Handle WP CLI message when the action has failed.
*
* @author Jeremy Pry
*
* @param int $action_id Action ID.
* @param Exception $exception Exception.
* @throws \WP_CLI\ExitException With failure message.
Expand Down

0 comments on commit 23f5aa8

Please sign in to comment.