PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.3.1
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.3.1
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 / CancelUpdate.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 2 years ago Job.php 2 years ago JobExecutable.php 2 years ago Logs.php 3 years ago PreserveDataFirstStep.php 3 years ago PreserveDataSecondStep.php 3 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
CancelUpdate.php
103 lines
1 <?php
2
3 namespace WPStaging\Backend\Modules\Jobs;
4
5 use WPStaging\Framework\Analytics\AnalyticsEventDto;
6
7 /**
8 * Class Cancel Update Processing
9 * @package WPStaging\Backend\Modules\Jobs
10 */
11 class CancelUpdate extends Job
12 {
13
14 /**
15 * Start Module
16 * @return bool
17 */
18 public function start()
19 {
20 $cloneData = $this->createCloneData();
21
22 if (!empty($this->options->jobIdentifier)) {
23 AnalyticsEventDto::enqueueCancelEvent($this->options->jobIdentifier);
24 }
25
26 if (empty($cloneData)) {
27 return true;
28 }
29
30 // Delete Cache Files
31 $this->deleteCacheFiles();
32
33 $this->returnFinish();
34
35 return true;
36 }
37
38 /**
39 * @return array
40 */
41 protected function createCloneData()
42 {
43 $clone = [];
44
45 if (!$this->check()) {
46 return $clone;
47 }
48
49 $clone["name"] = $this->options->clone;
50 $clone["number"] = $this->options->cloneNumber;
51 $clone["path"] = ABSPATH . $this->options->cloneDirectoryName;
52 $clone["prefix"] = ABSPATH . $this->options->prefix;
53
54 return $clone;
55 }
56
57 /**
58 * @return bool
59 */
60 public function check()
61 {
62 return (
63 isset($this->options) &&
64 isset($this->options->clone) &&
65 isset($this->options->cloneNumber) &&
66 isset($this->options->cloneDirectoryName) &&
67 isset($_POST["clone"]) &&
68 $_POST["clone"] === $this->options->clone
69 );
70 }
71
72 /**
73 * Get json response
74 * return json
75 */
76 private function returnFinish($message = '')
77 {
78
79 wp_die(json_encode([
80 'job' => 'delete',
81 'status' => true,
82 'message' => $message,
83 'error' => false,
84 'delete' => 'finished'
85 ]));
86 }
87
88
89 /**
90 * Delete Cache Files
91 */
92 protected function deleteCacheFiles()
93 {
94 $this->log("Cancel Updating: Deleting clone job's cache files...");
95
96 // Clean cache files
97 $this->cloneOptionCache->delete();
98 $this->filesIndexCache->delete();
99
100 $this->log("Updating process canceled");
101 }
102 }
103