← All changes
|
vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php
+21
-11
1.5.3
→
trunk
View file →
| @@ -4,15 +4,27 @@ | ||
| 4 | 4 | * Abstract class with common Queue Cleaner functionality. |
| 5 | 5 | */ |
| 6 | 6 | abstract class ActionScheduler_Abstract_QueueRunner extends ActionScheduler_Abstract_QueueRunner_Deprecated { |
| 7 | 7 | |
| 8 | - /** @var ActionScheduler_QueueCleaner */ | |
| 8 | + /** | |
| 9 | + * ActionScheduler_QueueCleaner instance. | |
| 10 | + * | |
| 11 | + * @var ActionScheduler_QueueCleaner | |
| 12 | + */ | |
| 9 | 13 | protected $cleaner; |
| 10 | 14 | |
| 11 | - /** @var ActionScheduler_FatalErrorMonitor */ | |
| 15 | + /** | |
| 16 | + * ActionScheduler_FatalErrorMonitor instance. | |
| 17 | + * | |
| 18 | + * @var ActionScheduler_FatalErrorMonitor | |
| 19 | + */ | |
| 12 | 20 | protected $monitor; |
| 13 | 21 | |
| 14 | - /** @var ActionScheduler_Store */ | |
| 22 | + /** | |
| 23 | + * ActionScheduler_Store instance. | |
| 24 | + * | |
| 25 | + * @var ActionScheduler_Store | |
| 26 | + */ | |
| 15 | 27 | protected $store; |
| 16 | 28 | |
| 17 | 29 | /** |
| 18 | 30 | * The created time. |
| @@ -26,13 +38,13 @@ | ||
| 26 | 38 | |
| 27 | 39 | /** |
| 28 | 40 | * ActionScheduler_Abstract_QueueRunner constructor. |
| 29 | 41 | * |
| 30 | - * @param ActionScheduler_Store $store Store object. | |
| 31 | - * @param ActionScheduler_FatalErrorMonitor $monitor Monitor object. | |
| 32 | - * @param ActionScheduler_QueueCleaner $cleaner Cleaner object. | |
| 42 | + * @param ActionScheduler_Store|null $store Store object. | |
| 43 | + * @param ActionScheduler_FatalErrorMonitor|null $monitor Monitor object. | |
| 44 | + * @param ActionScheduler_QueueCleaner|null $cleaner Cleaner object. | |
| 33 | 45 | */ |
| 34 | - public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) { | |
| 46 | + public function __construct( ?ActionScheduler_Store $store = null, ?ActionScheduler_FatalErrorMonitor $monitor = null, ?ActionScheduler_QueueCleaner $cleaner = null ) { | |
| 35 | 47 | |
| 36 | 48 | $this->created_time = microtime( true ); |
| 37 | 49 | |
| 38 | 50 | $this->store = $store ? $store : ActionScheduler_Store::instance(); |
| @@ -49,8 +61,9 @@ | ||
| 49 | 61 | * @throws \Exception When error running action. |
| 50 | 62 | */ |
| 51 | 63 | public function process_action( $action_id, $context = '' ) { |
| 52 | 64 | // Temporarily override the error handler while we process the current action. |
| 65 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler | |
| 53 | 66 | set_error_handler( |
| 54 | 67 | /** |
| 55 | 68 | * Temporary error handler which can catch errors and convert them into exceptions. This facilitates more |
| 56 | 69 | * robust error handling across all supported PHP versions. |
| @@ -192,9 +205,9 @@ | ||
| 192 | 205 | 'status' => ActionScheduler_Store::STATUS_FAILED, |
| 193 | 206 | 'date' => date_create( 'now', timezone_open( 'UTC' ) )->format( 'Y-m-d H:i:s' ), |
| 194 | 207 | 'date_compare' => '<', |
| 195 | 208 | 'per_page' => 1, |
| 196 | - 'offset' => $consistent_failure_threshold - 1 | |
| 209 | + 'offset' => $consistent_failure_threshold - 1, | |
| 197 | 210 | ); |
| 198 | 211 | |
| 199 | 212 | $first_failing_action_id = $this->store->query_actions( $query_args ); |
| 200 | 213 | |
| @@ -222,10 +235,8 @@ | ||
| 222 | 235 | } |
| 223 | 236 | |
| 224 | 237 | /** |
| 225 | 238 | * Run the queue cleaner. |
| 226 | - * | |
| 227 | - * @author Jeremy Pry | |
| 228 | 239 | */ |
| 229 | 240 | protected function run_cleanup() { |
| 230 | 241 | $this->cleaner->clean( 10 * $this->get_time_limit() ); |
| 231 | 242 | } |
| @@ -363,9 +374,8 @@ | ||
| 363 | 374 | |
| 364 | 375 | /** |
| 365 | 376 | * Process actions in the queue. |
| 366 | 377 | * |
| 367 | - * @author Jeremy Pry | |
| 368 | 378 | * @param string $context Optional identifier for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' |
| 369 | 379 | * Generally, this should be capitalised and not localised as it's a proper noun. |
| 370 | 380 | * @return int The number of actions processed. |
| 371 | 381 | */ |