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