PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
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 / JobExecutable.php
wp-staging / Backend / Modules / Jobs Last commit date
Cleaners 1 day ago Exceptions 1 day ago Cancel.php 1 day ago CancelUpdate.php 1 day ago Cloning.php 1 day ago CloningProcess.php 1 day ago Data.php 1 day ago Database.php 1 day ago Delete.php 1 day ago Directories.php 1 day ago Files.php 1 day ago Finish.php 1 day ago Job.php 1 day ago JobExecutable.php 1 day ago Logs.php 1 day ago PreserveDataFirstStep.php 1 day ago PreserveDataSecondStep.php 1 day ago ProcessLock.php 1 day ago Scan.php 1 day ago SearchReplace.php 1 day ago TotalStepsAreNumberOfTables.php 1 day ago Updating.php 1 day ago
JobExecutable.php
145 lines
1 <?php
2
3 namespace WPStaging\Backend\Modules\Jobs;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Traits\MemoryExhaustTrait;
7 use WPStaging\Framework\Utils\Strings;
8 use WPStaging\Framework\Utils\ServerVars;
9
10
11 if (!defined("WPINC")) {
12 die;
13 }
14
15
16
17
18
19
20 abstract class JobExecutable extends Job
21 {
22 use MemoryExhaustTrait;
23
24
25
26
27 protected $strUtil;
28
29
30
31
32 protected $response = [
33 "status" => false,
34 "percentage" => 0,
35 "total" => 0,
36 "step" => 0,
37 "last_msg" => '',
38 ];
39
40
41
42
43 public function __construct()
44 {
45 parent::__construct();
46
47
48 $this->calculateTotalSteps();
49
50
51
52 @ignore_user_abort(true);
53
54
55 WPStaging::make(ServerVars::class)->setTimeLimit(0);
56
57
58 @ini_set('max_input_time', '-1');
59
60
61 @ini_set('pcre.backtrack_limit', (string)PHP_INT_MAX);
62
63 $this->strUtil = WPStaging::make(Strings::class);
64 }
65
66
67
68
69
70
71
72 protected function prepareResponse($status = false, $incrementCurrentStep = true)
73 {
74 if ($incrementCurrentStep) {
75 $this->options->currentStep++;
76 }
77
78 $percentage = 0;
79 if (isset($this->options->currentStep) && isset($this->options->totalSteps) && $this->options->totalSteps > 0) {
80 $percentage = round(($this->options->currentStep / $this->options->totalSteps) * 100);
81 $percentage = ($percentage > 100) ? 100 : $percentage;
82 }
83
84 $this->removeMemoryExhaustErrorTmpFile();
85 return $this->response = [
86 "status" => $status,
87 "percentage" => $percentage,
88 "total" => $this->options->totalSteps,
89 "step" => $this->options->currentStep,
90 "job" => $this->options->currentJob,
91 "last_msg" => $this->logger->getLastLogMsg(),
92 "job_done" => $status,
93 ];
94 }
95
96
97
98
99
100 public function start()
101 {
102
103 $this->run();
104
105
106 $this->saveOptions();
107
108 return (object) $this->response;
109 }
110
111
112
113
114 protected function run()
115 {
116
117 for ($i = 0; $i < $this->options->totalSteps; $i++) {
118
119 if (!$this->execute()) {
120 break;
121 }
122
123
124
125
126 if ($this->settings->cpuLoad === 'low') {
127 return (object) $this->response;
128 }
129 }
130 }
131
132
133
134
135
136 abstract protected function calculateTotalSteps();
137
138
139
140
141
142
143 abstract protected function execute();
144 }
145