ActionScheduler_Abstract_QueueRunner::process_action()
Process an individual action.
Метод класса: ActionScheduler_Abstract_QueueRunner{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$ActionScheduler_Abstract_QueueRunner = new ActionScheduler_Abstract_QueueRunner(); $ActionScheduler_Abstract_QueueRunner->process_action( $action_id, $context );
- $action_id(int) (обязательный)
- The action ID to process.
- $context(строка)
- Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' Generally, this should be capitalised and not localised as it's a proper noun.
По умолчанию: ''
Код ActionScheduler_Abstract_QueueRunner::process_action() ActionScheduler Abstract QueueRunner::process action WC 8.7.0
public function process_action( $action_id, $context = '' ) { // Temporarily override the error handler while we process the current action. set_error_handler( /** * Temporary error handler which can catch errors and convert them into exceptions. This faciliates more * robust error handling across all supported PHP versions. * * @throws Exception * * @param int $type Error level expressed as an integer. * @param string $message Error message. */ function ( $type, $message ) { throw new Exception( $message ); }, E_USER_ERROR | E_RECOVERABLE_ERROR ); /* * The nested try/catch structure is required because we potentially need to convert thrown errors into * exceptions (and an exception thrown from a catch block cannot be caught by a later catch block in the *same* * structure). */ try { try { $valid_action = false; do_action( 'action_scheduler_before_execute', $action_id, $context ); if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) { do_action( 'action_scheduler_execution_ignored', $action_id, $context ); return; } $valid_action = true; do_action( 'action_scheduler_begin_execute', $action_id, $context ); $action = $this->store->fetch_action( $action_id ); $this->store->log_execution( $action_id ); $action->execute(); do_action( 'action_scheduler_after_execute', $action_id, $action, $context ); $this->store->mark_complete( $action_id ); } catch ( Throwable $e ) { // Throwable is defined when executing under PHP 7.0 and up. We convert it to an exception, for // compatibility with ActionScheduler_Logger. throw new Exception( $e->getMessage(), $e->getCode(), $e ); } } catch ( Exception $e ) { // This catch block exists for compatibility with PHP 5.6. $this->handle_action_error( $action_id, $e, $context, $valid_action ); } finally { restore_error_handler(); } if ( isset( $action ) && is_a( $action, 'ActionScheduler_Action' ) && $action->get_schedule()->is_recurring() ) { $this->schedule_next_instance( $action, $action_id ); } }