PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.0
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.0
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / woocommerce / action-scheduler / classes / ActionScheduler_AsyncRequest_QueueRunner.php
hostinger-reach / vendor / woocommerce / action-scheduler / classes Last commit date
WP_CLI 10 months ago abstracts 10 months ago actions 10 months ago data-stores 10 months ago migration 10 months ago schedules 10 months ago schema 10 months ago ActionScheduler_ActionClaim.php 10 months ago ActionScheduler_ActionFactory.php 10 months ago ActionScheduler_AdminView.php 10 months ago ActionScheduler_AsyncRequest_QueueRunner.php 10 months ago ActionScheduler_Compatibility.php 10 months ago ActionScheduler_DataController.php 10 months ago ActionScheduler_DateTime.php 10 months ago ActionScheduler_Exception.php 10 months ago ActionScheduler_FatalErrorMonitor.php 10 months ago ActionScheduler_InvalidActionException.php 10 months ago ActionScheduler_ListTable.php 10 months ago ActionScheduler_LogEntry.php 10 months ago ActionScheduler_NullLogEntry.php 10 months ago ActionScheduler_OptionLock.php 10 months ago ActionScheduler_QueueCleaner.php 10 months ago ActionScheduler_QueueRunner.php 10 months ago ActionScheduler_RecurringActionScheduler.php 10 months ago ActionScheduler_SystemInformation.php 10 months ago ActionScheduler_Versions.php 10 months ago ActionScheduler_WPCommentCleaner.php 10 months ago ActionScheduler_wcSystemStatus.php 10 months ago
ActionScheduler_AsyncRequest_QueueRunner.php
94 lines
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 /**
6 * ActionScheduler_AsyncRequest_QueueRunner class.
7 */
8 class ActionScheduler_AsyncRequest_QueueRunner extends WP_Async_Request {
9
10 /**
11 * Data store for querying actions
12 *
13 * @var ActionScheduler_Store
14 */
15 protected $store;
16
17 /**
18 * Prefix for ajax hooks
19 *
20 * @var string
21 */
22 protected $prefix = 'as';
23
24 /**
25 * Action for ajax hooks
26 *
27 * @var string
28 */
29 protected $action = 'async_request_queue_runner';
30
31 /**
32 * Initiate new async request.
33 *
34 * @param ActionScheduler_Store $store Store object.
35 */
36 public function __construct( ActionScheduler_Store $store ) {
37 parent::__construct();
38 $this->store = $store;
39 }
40
41 /**
42 * Handle async requests
43 *
44 * Run a queue, and maybe dispatch another async request to run another queue
45 * if there are still pending actions after completing a queue in this request.
46 */
47 protected function handle() {
48 do_action( 'action_scheduler_run_queue', 'Async Request' ); // run a queue in the same way as WP Cron, but declare the Async Request context.
49
50 $sleep_seconds = $this->get_sleep_seconds();
51
52 if ( $sleep_seconds ) {
53 sleep( $sleep_seconds );
54 }
55
56 $this->maybe_dispatch();
57 }
58
59 /**
60 * If the async request runner is needed and allowed to run, dispatch a request.
61 */
62 public function maybe_dispatch() {
63 if ( ! $this->allow() ) {
64 return;
65 }
66
67 $this->dispatch();
68 ActionScheduler_QueueRunner::instance()->unhook_dispatch_async_request();
69 }
70
71 /**
72 * Only allow async requests when needed.
73 *
74 * Also allow 3rd party code to disable running actions via async requests.
75 */
76 protected function allow() {
77
78 if ( ! has_action( 'action_scheduler_run_queue' ) || ActionScheduler::runner()->has_maximum_concurrent_batches() || ! $this->store->has_pending_actions_due() ) {
79 $allow = false;
80 } else {
81 $allow = true;
82 }
83
84 return apply_filters( 'action_scheduler_allow_async_request_runner', $allow );
85 }
86
87 /**
88 * Chaining async requests can crash MySQL. A brief sleep call in PHP prevents that.
89 */
90 protected function get_sleep_seconds() {
91 return apply_filters( 'action_scheduler_async_request_sleep_seconds', 5, $this );
92 }
93 }
94