PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.0
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.0
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 / Backend / Modules / Jobs / ProcessLock.php
wp-staging / Backend / Modules / Jobs Last commit date
Cleaners 3 months ago Exceptions 5 years ago Cancel.php 6 months ago CancelUpdate.php 6 months ago Cloning.php 1 week ago CloningProcess.php 1 year ago Data.php 6 months ago Database.php 3 months ago Delete.php 4 months ago Directories.php 4 months ago Files.php 2 months ago Finish.php 2 months ago Job.php 1 week ago JobExecutable.php 6 months ago Logs.php 3 years ago PreserveDataFirstStep.php 1 month ago PreserveDataSecondStep.php 1 month ago ProcessLock.php 1 year ago Scan.php 4 months ago SearchReplace.php 5 months ago TotalStepsAreNumberOfTables.php 5 years ago Updating.php 1 week ago
ProcessLock.php
86 lines
1 <?php
2
3 namespace WPStaging\Backend\Modules\Jobs;
4
5 /**
6 * Class Cloning
7 * @package WPStaging\Backend\Modules\Jobs
8 */
9 class ProcessLock extends JobExecutable
10 {
11
12 /**
13 * Check if any process is already running
14 * @return boolean
15 */
16 public function isRunning()
17 {
18 // Another process is running
19 if (parent::isRunning()) {
20 $this->log("Another process is running");
21
22 $message = __('Hold on, another WP STAGING process is already running...', 'wp-staging');
23
24 require_once WPSTG_VIEWS_DIR . "clone/ajax/process-lock.php";
25
26 wp_die();
27 }
28
29 // No other process running
30
31 return false;
32 }
33
34 /**
35 * Check if any process is already running, if running return a json encoded response for Swal Modal,
36 * Otherwise return false
37 *
38 * @return false|array
39 */
40 public function ajaxIsRunning()
41 {
42 if (parent::isRunning()) {
43 return [
44 'success' => false,
45 'type' => 'processLock',
46 // TODO: Create a Swal Response Class and Js library to handle that response or, Implement own Swal alternative
47 'swalOptions' => [
48 'title' => __('Error!', 'wp-staging'),
49 'html' => __('Hold on, another WP STAGING process is already running...', 'wp-staging'),
50 'confirmButtonText' => __('Stop other process', 'wp-staging'),
51 'showCancelButton' => true,
52 ],
53 ];
54 }
55
56 return false;
57 }
58
59 /**
60 * remove process lock value
61 */
62 public function restart()
63 {
64 unset($this->options->isRunning);
65 $this->cloneOptionCache->delete();
66 $this->filesIndexCache->delete();
67 }
68
69 /**
70 * abstract
71 * @return void
72 */
73 protected function calculateTotalSteps()
74 {
75 }
76
77 /**
78 * abstract
79 * @return bool
80 */
81 protected function execute()
82 {
83 return false;
84 }
85 }
86