PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.8.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.8.2
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 5 years ago Exceptions 5 years ago Cancel.php 2 years ago CancelUpdate.php 2 years ago Cloning.php 2 years ago CloningProcess.php 2 years ago Data.php 2 years ago Database.php 2 years ago Delete.php 2 years ago Directories.php 2 years ago Files.php 2 years ago Finish.php 1 year ago Job.php 2 years ago JobExecutable.php 2 years ago Logs.php 3 years ago PreserveDataFirstStep.php 3 years ago PreserveDataSecondStep.php 2 years ago ProcessLock.php 2 years ago Scan.php 2 years ago SearchReplace.php 2 years ago TotalStepsAreNumberOfTables.php 5 years ago Updating.php 2 years 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_PLUGIN_DIR . "Backend/views/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