Notice: include(): Read of 10911 bytes failed with errno=12 Cannot allocate memory in /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php on line 164
Notice: include(): Read of 10911 bytes failed with errno=12 Cannot allocate memory in /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php on line 164
tch ( Exception $e ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* Translators: %s is the exception message. */
esc_html__( 'It was not possible to determine a valid cut-off time: %s.', 'action-scheduler' ),
esc_html( $e->getMessage() )
),
'3.5.5'
);
return array();
}
/**
* Filter the statuses when cleaning the queue.
*
* @param string[] $default_statuses_to_purge Action statuses to clean.
*/
$statuses_to_purge = apply_filters( 'action_scheduler_default_cleaner_statuses', $this->default_statuses_to_purge );
// Only an explicit empty array disables the purge; a non-array (e.g. a filter that forgot to return) falls back to the defaults.
if ( ! is_array( $statuses_to_purge ) ) {
$statuses_to_purge = $this->default_statuses_to_purge;
}
/**
* Filter whether failed actions are purged. Return false to disable failed action cleanup.
*
* @since 4.0.0
*
* @param bool $enabled Whether failed actions should be purged. Default true.
*/
$clean_failed = (bool) apply_filters( 'action_scheduler_enable_failed_action_cleanup', true );
$deleted_failed_entries = array();
// Backward compatibility note: if store already purging the failed statuses, don't change the behaviour.
if ( $clean_failed && ! in_array( ActionScheduler_Store::STATUS_FAILED, $statuses_to_purge, true ) ) {
// Use a fixed default batch size to ensure that the cleanup of failed actions does not interfere with the regular cleanup.
$deleted_failed_entries = $this->clean_actions( array( ActionScheduler_Store::STATUS_FAILED ), $cutoff_failed, 20 );
}
$deleted_entries = array();
if ( ! empty( $statuses_to_purge ) ) {
$deleted_entries = $this->clean_actions( $statuses_to_purge, $cutoff, $this->get_batch_size() );
}
return array_merge( $deleted_failed_entries, $deleted_entries );
}
/**
* Delete selected actions based on status and date. The function's behavior depends on the context:
* - For scheduled cleanup actions, the function operates within execution budget constraints optimized for high-traffic stores.
* - Otherwise, it strictly follows the provided parameters without the scheduled cleanup optimizations.
*
* @param string[] $statuses_to_purge List of action statuses to purge. Defaults to canceled, complete.
* @param DateTime $cutoff_date Date limit for selecting actions. Defaults to 31 days ago.
* @param int|null $batch_size Maximum number of actions per status to delete. Defaults to 20.
* @param string $context Calling process context. Defaults to `old`.
*
* @return array Actions deleted.
*/
public function clean_actions( array $statuses_to_purge, DateTime $cutoff_date, $batch_size = null, $context = 'old' ) {
$batch_size = ! is_null( $batch_size ) ? $batch_size : $this->batch_size;
$cutoff = ! is_null( $cutoff_date ) ? $cutoff_date : as_get_datetime_object( $this->month_in_seconds . ' seconds ago' );
$lifespan = time() - $cutoff->getTimestamp();
$statuses_to_purge = empty( $statuses_to_purge ) ? $this->default_statuses_to_purge : $statuses_to_purge;
// When deletion is performed as a separate action, we can enforce a minimum batch size to achieve consistent deletion throughput.
// For inline cleanup during a queue run, the batch size should remain unchanged to avoid increasing the process footprint.
$is_scheduled_cleanup = doing_action( self::RUN_SCHEDULED_CLEANER_HOOK )
|| doing_action( self::CONTINUE_SCHEDULED_CLEANER_HOOK );
// 250 balances replication safety, backlog clearance speed, and claim slot duration on high-volume stores.
$iteration_batch_size = $is_scheduled_cleanup ? max( 250, $batch_size ) : $batch_size;
$iteration_unused_budget = 0;
$continue_scheduled_cleanup = false;
if ( $is_scheduled_cleanup ) {
// Sort the statuses to optimize execution budget usage based on the typical status distribution.
usort(
$statuses_to_purge,
static function( $a, $b ) {
// Place the 'canceled' status first to help ensure that any unspent execution budget can be used for processing other statuses.
if ( ActionScheduler_Store::STATUS_CANCELED === $a ) {
return -1;
}
if ( ActionScheduler_Store::STATUS_CANCELED === $b ) {
return 1;
}
// Place the 'complete' status at the end to use any remaining execution budget for processing.
if ( ActionScheduler_Store::STATUS_COMPLETE === $a ) {
return 1;
}
if ( ActionScheduler_Store::STATUS_COMPLETE === $b ) {
return -1;
}
return 0;
}
);
}
$deleted_actions = array();
foreach ( $statuses_to_purge as $status ) {
$iteration_execution_budget = $iteration_batch_size + $iteration_unused_budget;
$actions_to_delete = $this->store->query_actions(
array(
'status' => $status,
'modified' => $cutoff,
'modified_compare' => '<=',
'per_page' => $iteration_execution_budget,
'orderby' => 'none',
)
);
$deleted_actions[] = $this->delete_actions( $actions_to_delete, $lifespan, $context );
$fetched_actions_count = count( $actions_to_delete );
$iteration_unused_budget = $is_scheduled_cleanup ? ( $iteration_execution_budget - $fetched_actions_count ) : 0;
$continue_scheduled_cleanup = $continue_scheduled_cleanup || ( $iteration_execution_budget === $fetched_actions_count );
}
// When called from the scheduled cleanup hook, unique=true prevents duplicates at the SQL level. When called
// from a continuation, that same flag would match the running entry, so check for a pending continuation first.
$called_from_run = doing_action( self::RUN_SCHEDULED_CLEANER_HOOK );
if ( $is_scheduled_cleanup && $continue_scheduled_cleanup && ( $called_from_run || ! $this->has_pending_continuation() ) ) {
as_schedule_single_action( time(), self::CONTINUE_SCHEDULED_CLEANER_HOOK, array(), 'ActionScheduler', $called_from_run, 0 );
}
return array_merge( array(), ...$deleted_actions );
}
/**
* Whether a continuation of the cleanup is already queued.
*
* @return bool
*/
private function has_pending_continuation() {
$pending = as_get_scheduled_actions(
array(
'hook' => self::CONTINUE_SCHEDULED_CLEANER_HOOK,
'status' => ActionScheduler_Store::STATUS_PENDING,
'per_page' => 1,
),
'ids'
);
return ! empty( $pending );
}
/**
* Delete actions.
*
* @param int[] $actions_to_delete List of action IDs to delete.
* @param int $lifespan Minimum scheduled age in seconds of the actions being deleted.
* @param string $context Context of the delete request.
*
* @return int[] Deleted action IDs.
*/
private function delete_actions( array $actions_to_delete, $lifespan, $context = 'old' ) {
$deleted_actions = array();
foreach ( $actions_to_delete as $action_id ) {
try {
$this->store->delete_action( $action_id );
$deleted_actions[] = $action_id;
} catch ( Exception $e ) {
/**
* Notify 3rd party code of exceptions when deleting a completed action older than the retention period
*
* This hook provides a way for 3rd party code to log or otherwise handle exceptions relating to their
* actions.
*
* @param int $action_id The scheduled actions ID in the data store
* @param Exception $e The exception thrown when attempting to delete the action from the data store
* @param int $lifespan The retention period, in seconds, for old actions
* @param int $count_of_actions_to_delete The number of old actions being deleted in this batch
* @since 2.0.0
*/
do_action( "action_scheduler_failed_{$context}_action_deletion", $action_id, $e, $lifespan, count( $actions_to_delete ) );
}
}
return $deleted_actions;
}
/**
* Unclaim pending actions that have not been run within a given time limit.
*
* When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed
* as a parameter is 10x the time limit used for queue processing.
*
* @param int $time_limit The number of seconds to allow a queue to run before unclaiming its pending actions. Default 300 (5 minutes).
*/
public function reset_timeouts( $time_limit = 300 ) {
$timeout = apply_filters( 'action_scheduler_timeout_period', $time_limit );
if ( $timeout < 0 ) {
return;
}
$cutoff = as_get_datetime_object( $timeout . ' seconds ago' );
$actions_to_reset = $this->store->query_actions(
array(
'status' => ActionScheduler_Store::STATUS_PENDING,
'modified' => $cutoff,
'modified_compare' => '<=',
'claimed' => true,
'per_page' => $this->get_batch_size(),
'orderby' => 'none',
)
);
foreach ( $actions_to_reset as $action_id ) {
$this->store->unclaim_action( $action_id );
do_action( 'action_scheduler_reset_action', $action_id );
}
}
/**
* Mark actions that have been running for more than a given time limit as failed, based on
* the assumption some uncatchable and unloggable fatal error occurred during processing.
*
* When called by ActionScheduler_Abstract_QueueRunner::run_cleanup(), the time limit passed
* as a parameter is 10x the time limit used for queue processing.
*
* @param int $time_limit The number of seconds to allow an action to run before it is considered to have failed. Default 300 (5 minutes).
*/
public function mark_failures( $time_limit = 300 ) {
$timeout = apply_filters( 'action_scheduler_failure_period', $time_limit );
if ( $timeout < 0 ) {
return;
}
$cutoff = as_get_datetime_object( $timeout . ' seconds ago' );
$actions_to_reset = $this->store->query_actions(
array(
'status' => ActionScheduler_Store::STATUS_RUNNING,
'modified' => $cutoff,
'modified_compare' => '<=',
'per_page' => $this->get_batch_size(),
'orderby' => 'none',
)
);
foreach ( $actions_to_reset as $action_id ) {
$this->store->mark_failure( $action_id );
do_action( 'action_scheduler_failed_action', $action_id, $timeout );
}
}
/**
* Do all of the cleaning actions.
*
* @param int $time_limit The number of seconds to use as the timeout and failure period. Default 300 (5 minutes).
*/
public function clean( $time_limit = 300 ) {
$this->delete_old_actions();
$this->reset_timeouts( $time_limit );
$this->mark_failures( $time_limit );
}
/**
* Get the batch size for cleaning the queue.
*
* @return int
*/
protected function get_batch_size() {
/**
* Filter the batch size when cleaning the queue.
*
* @param int $batch_size The number of actions to clean in one batch.
*/
return absint( apply_filters( 'action_scheduler_cleanup_batch_size', $this->batch_size ) );
}
}
Fatal error: Uncaught Error: Class "ActionScheduler_QueueCleaner" not found in /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php:52
Stack trace:
#0 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/ActionScheduler_QueueRunner.php(63): ActionScheduler_Abstract_QueueRunner->__construct(NULL, NULL, NULL)
#1 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/ActionScheduler_QueueRunner.php(48): ActionScheduler_QueueRunner->__construct()
#2 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php(69): ActionScheduler_QueueRunner::instance()
#3 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php(189): ActionScheduler::runner()
#4 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/action-scheduler.php(60): ActionScheduler::init('/home/parkwood/...')
#5 /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/ActionScheduler_Versions.php(115): action_scheduler_initialize_4_dot_0_dot_0()
#6 /home/parkwood/public_html/wp-includes/class-wp-hook.php(339): ActionScheduler_Versions::initialize_latest_version()
#7 /home/parkwood/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array)
#8 /home/parkwood/public_html/wp-includes/plugin.php(522): WP_Hook->do_action(Array)
#9 /home/parkwood/public_html/wp-settings.php(622): do_action('plugins_loaded')
#10 /home/parkwood/public_html/wp-config.php(95): require_once('/home/parkwood/...')
#11 /home/parkwood/public_html/wp-load.php(50): require_once('/home/parkwood/...')
#12 /home/parkwood/public_html/wp-blog-header.php(13): require_once('/home/parkwood/...')
#13 /home/parkwood/public_html/index.php(17): require('/home/parkwood/...')
#14 {main}
thrown in /home/parkwood/public_html/wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_Abstract_QueueRunner.php on line 52