PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.0.6
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.0.6
4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Framework / BackgroundProcessing / Demo.php
wp-staging / Framework / BackgroundProcessing Last commit date
Exceptions 5 years ago Action.php 2 years ago BackgroundProcessingServiceProvider.php 2 years ago Demo.php 4 years ago FeatureDetection.php 2 years ago Queue.php 2 years ago QueueActionAware.php 4 years ago QueueProcessor.php 4 years ago WithQueueAwareness.php 3 years ago
Demo.php
39 lines
1 <?php
2
3 /**
4 * Runs a Queue Background Processing Demo from the browser.
5 *
6 * Go to https:<site>/?wpstg_q_demo to run the demo queueing 100 actions and close all browser windows on the site.
7 *
8 * Go to https:<site>/?wpstg_q_demo=<n> to run the demo queueing <n> actions and close all browser windows on the site.
9 *
10 * @since TBD
11 *
12 * @package WPStaging\Framework\BackgroundProcessing
13 */
14
15 namespace WPStaging\Framework\BackgroundProcessing;
16
17 use WPStaging\Core\WPStaging;
18
19 class Demo
20 {
21 public function run($count)
22 {
23 $queue = WPStaging::getInstance()->getContainer()->make(Queue::class);
24
25 foreach (range(1, $count) as $k) {
26 $queue->enqueueAction(self::class . '::' . 'writeToLog', [$k]);
27 \WPStaging\functions\debug_log("Enqueued Action {$k}");
28 }
29 }
30
31 public function writeToLog($k)
32 {
33 $interval = mt_rand(0, 2);
34 sleep($interval);
35 $pid = getmypid();
36 \WPStaging\functions\debug_log("Action {$k} done [PID {$pid}]!");
37 }
38 }
39