PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 3.0.2
WP STAGING – WordPress Backups, Restore, Migration & Clone v3.0.2
4.11.2 4.11.1 4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.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 / CancelUpdate.php
wp-staging / Backend / Modules / Jobs Last commit date
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 3 years ago Files.php 3 years ago Finish.php 3 years ago Job.php 3 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 3 years ago SearchReplace.php 3 years ago TotalStepsAreNumberOfTables.php 5 years ago Updating.php 3 years ago Verify.php 3 years ago
CancelUpdate.php
102 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 // Delete Cache Files
30 $this->deleteCacheFiles();
31
32 $this->returnFinish();
33
34 return true;
35 }
36
37 /**
38 * @return array
39 */
40 protected function createCloneData()
41 {
42 $clone = [];
43
44 if (!$this->check()) {
45 return $clone;
46 }
47
48 $clone["name"] = $this->options->clone;
49 $clone["number"] = $this->options->cloneNumber;
50 $clone["path"] = ABSPATH . $this->options->cloneDirectoryName;
51 $clone["prefix"] = ABSPATH . $this->options->prefix;
52
53 return $clone;
54 }
55
56 /**
57 * @return bool
58 */
59 public function check()
60 {
61 return (
62 isset($this->options) &&
63 isset($this->options->clone) &&
64 isset($this->options->cloneNumber) &&
65 isset($this->options->cloneDirectoryName) &&
66 isset($_POST["clone"]) &&
67 $_POST["clone"] === $this->options->clone
68 );
69 }
70
71 /**
72 * Get json response
73 * return json
74 */
75 private function returnFinish($message = '')
76 {
77
78 wp_die(json_encode([
79 'job' => 'delete',
80 'status' => true,
81 'message' => $message,
82 'error' => false,
83 'delete' => 'finished'
84 ]));
85 }
86
87
88 /**
89 * Delete Cache Files
90 */
91 protected function deleteCacheFiles()
92 {
93 $this->log("Cancel Updating: Deleting clone job's cache files...");
94
95 // Clean cache files
96 $this->cache->delete("clone_options");
97 $this->cache->delete("files_to_copy");
98
99 $this->log("Updating process canceled");
100 }
101 }
102