PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
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 3 months ago Exceptions 5 years ago Cancel.php 7 months ago CancelUpdate.php 7 months ago Cloning.php 2 weeks ago CloningProcess.php 1 year ago Data.php 7 months ago Database.php 3 months ago Delete.php 4 months ago Directories.php 4 months ago Files.php 1 week ago Finish.php 2 months ago Job.php 2 weeks ago JobExecutable.php 7 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 2 weeks 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
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->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->cloneOptionCache->delete();
97 $this->filesIndexCache->delete();
98
99 $this->log("Updating process canceled");
100 }
101 }
102