Version Description
- Hotfix: Fix CLONE PUSH BACKUP on Medium and High CPU Load on WP STAGING 2.9.1. Improve Performance of database backup #1492
Download this release
Release Info
Developer | ReneHermi |
Plugin | WP Staging – DB & File Duplicator & Migration |
Version | 2.9.2 |
Comparing to | |
See all releases |
Code changes from version 2.9.1 to 2.9.2
- Backend/Modules/Jobs/Files.php +5 -1
- Framework/Filesystem/FileObject.php +27 -3
- Framework/Traits/ResourceTrait.php +6 -2
- constantsFree.php +1 -1
- opcacheBootstrap.php +1 -1
- readme.txt +7 -2
- wp-staging.php +1 -1
Backend/Modules/Jobs/Files.php
CHANGED
@@ -263,7 +263,7 @@ class Files extends JobExecutable
|
|
263 |
$this->file->seek($this->options->copiedFiles - 1);
|
264 |
}
|
265 |
|
266 |
-
$this->file->setFlags(FileObject::
|
267 |
|
268 |
for ($i = 0; $i < $this->maxFilesPerRun; $i++) {
|
269 |
// Increment copied files
|
@@ -277,6 +277,10 @@ class Files extends JobExecutable
|
|
277 |
|
278 |
$file = trim($this->file->fgets());
|
279 |
|
|
|
|
|
|
|
|
|
280 |
$this->copyFile($file);
|
281 |
}
|
282 |
|
263 |
$this->file->seek($this->options->copiedFiles - 1);
|
264 |
}
|
265 |
|
266 |
+
$this->file->setFlags(FileObject::DROP_NEW_LINE);
|
267 |
|
268 |
for ($i = 0; $i < $this->maxFilesPerRun; $i++) {
|
269 |
// Increment copied files
|
277 |
|
278 |
$file = trim($this->file->fgets());
|
279 |
|
280 |
+
if (empty($file)) {
|
281 |
+
continue;
|
282 |
+
}
|
283 |
+
|
284 |
$this->copyFile($file);
|
285 |
}
|
286 |
|
Framework/Filesystem/FileObject.php
CHANGED
@@ -10,6 +10,7 @@ use LimitIterator;
|
|
10 |
use RuntimeException;
|
11 |
use SplFileObject;
|
12 |
use WPStaging\Core\WPStaging;
|
|
|
13 |
|
14 |
class FileObject extends SplFileObject
|
15 |
{
|
@@ -33,6 +34,9 @@ class FileObject extends SplFileObject
|
|
33 |
*/
|
34 |
private $lockHandle = null;
|
35 |
|
|
|
|
|
|
|
36 |
public function __construct($fullPath, $openMode = self::MODE_READ)
|
37 |
{
|
38 |
$fullPath = untrailingslashit($fullPath);
|
@@ -43,7 +47,7 @@ class FileObject extends SplFileObject
|
|
43 |
|
44 |
try {
|
45 |
parent::__construct($fullPath, $openMode);
|
46 |
-
} catch (
|
47 |
// If this fails, it will throw an exception.
|
48 |
WPStaging::make(DiskWriteCheck::class)->testDiskIsWriteable();
|
49 |
|
@@ -70,6 +74,7 @@ class FileObject extends SplFileObject
|
|
70 |
/**
|
71 |
* @param int $lines
|
72 |
* @return array
|
|
|
73 |
*/
|
74 |
public function readBottomLines($lines)
|
75 |
{
|
@@ -105,7 +110,7 @@ class FileObject extends SplFileObject
|
|
105 |
} while ($this->valid() && !is_array($backupMetadata));
|
106 |
|
107 |
if (!is_array($backupMetadata)) {
|
108 |
-
throw new
|
109 |
}
|
110 |
|
111 |
return $backupMetadata;
|
@@ -120,6 +125,10 @@ class FileObject extends SplFileObject
|
|
120 |
return $this->existingMetadataPosition;
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
123 |
public function totalLines()
|
124 |
{
|
125 |
if ($this->totalLines !== null) {
|
@@ -135,10 +144,19 @@ class FileObject extends SplFileObject
|
|
135 |
|
136 |
/**
|
137 |
* Override SplFileObject::seek()
|
138 |
-
* Alternative function for SplFileObject::seek() that behaves identical in all PHP Versions.
|
|
|
|
|
|
|
139 |
* @see https://bugs.php.net/bug.php?id=81551
|
140 |
*
|
|
|
|
|
|
|
|
|
|
|
141 |
* @param int $offset The zero-based line number to seek to.
|
|
|
142 |
*/
|
143 |
#[\ReturnTypeWillChange]
|
144 |
public function seek($offset)
|
@@ -160,6 +178,10 @@ class FileObject extends SplFileObject
|
|
160 |
$offset -= 1;
|
161 |
}
|
162 |
|
|
|
|
|
|
|
|
|
163 |
$this->rewind();
|
164 |
for ($i = 0; $i < $offset; $i++) {
|
165 |
$this->next();
|
@@ -169,6 +191,8 @@ class FileObject extends SplFileObject
|
|
169 |
break;
|
170 |
}
|
171 |
}
|
|
|
|
|
172 |
}
|
173 |
|
174 |
/**
|
10 |
use RuntimeException;
|
11 |
use SplFileObject;
|
12 |
use WPStaging\Core\WPStaging;
|
13 |
+
use WPStaging\Pro\Backup\Exceptions\DiskNotWritableException;
|
14 |
|
15 |
class FileObject extends SplFileObject
|
16 |
{
|
34 |
*/
|
35 |
private $lockHandle = null;
|
36 |
|
37 |
+
/**
|
38 |
+
* @throws DiskNotWritableException
|
39 |
+
*/
|
40 |
public function __construct($fullPath, $openMode = self::MODE_READ)
|
41 |
{
|
42 |
$fullPath = untrailingslashit($fullPath);
|
47 |
|
48 |
try {
|
49 |
parent::__construct($fullPath, $openMode);
|
50 |
+
} catch (Exception $e) {
|
51 |
// If this fails, it will throw an exception.
|
52 |
WPStaging::make(DiskWriteCheck::class)->testDiskIsWriteable();
|
53 |
|
74 |
/**
|
75 |
* @param int $lines
|
76 |
* @return array
|
77 |
+
* @throws Exception
|
78 |
*/
|
79 |
public function readBottomLines($lines)
|
80 |
{
|
110 |
} while ($this->valid() && !is_array($backupMetadata));
|
111 |
|
112 |
if (!is_array($backupMetadata)) {
|
113 |
+
throw new RuntimeException('Could not find metadata in the backup.');
|
114 |
}
|
115 |
|
116 |
return $backupMetadata;
|
125 |
return $this->existingMetadataPosition;
|
126 |
}
|
127 |
|
128 |
+
/**
|
129 |
+
* @return mixed int|null
|
130 |
+
* @throws Exception
|
131 |
+
*/
|
132 |
public function totalLines()
|
133 |
{
|
134 |
if ($this->totalLines !== null) {
|
144 |
|
145 |
/**
|
146 |
* Override SplFileObject::seek()
|
147 |
+
* Alternative function for SplFileObject::seek() that behaves identical in all PHP Versions.
|
148 |
+
*
|
149 |
+
* There was a major change in PHP 8.0.1 where after using `SplFileObject::seek($line)`, the first subsequent
|
150 |
+
* call to `SplFileObject::fgets()` does not increase the line pointer anymore as it did in earlier version since PHP 5.x
|
151 |
* @see https://bugs.php.net/bug.php?id=81551
|
152 |
*
|
153 |
+
* Note: This will remove READ_AHEAD flag while execution to deliver reliable and identical results as READ_AHEAD tells
|
154 |
+
* SplFileObject to read on next() and rewind() too which our custom seek() makes use of.
|
155 |
+
* This would disturb this seek() implementation and would lead to fatal errors if 'cpu load' setting is 'medium' or 'high'
|
156 |
+
*
|
157 |
+
*
|
158 |
* @param int $offset The zero-based line number to seek to.
|
159 |
+
* @throws Exception
|
160 |
*/
|
161 |
#[\ReturnTypeWillChange]
|
162 |
public function seek($offset)
|
178 |
$offset -= 1;
|
179 |
}
|
180 |
|
181 |
+
$originalFlags = $this->getFlags();
|
182 |
+
$newFlags = $originalFlags & ~self::READ_AHEAD;
|
183 |
+
$this->setFlags($newFlags);
|
184 |
+
|
185 |
$this->rewind();
|
186 |
for ($i = 0; $i < $offset; $i++) {
|
187 |
$this->next();
|
191 |
break;
|
192 |
}
|
193 |
}
|
194 |
+
|
195 |
+
$this->setFlags($originalFlags);
|
196 |
}
|
197 |
|
198 |
/**
|
Framework/Traits/ResourceTrait.php
CHANGED
@@ -95,6 +95,10 @@ trait ResourceTrait
|
|
95 |
// TODO Recursion for xDebug? Recursion is bad idea will cause more resource usage, need to avoid it.
|
96 |
|
97 |
/**
|
|
|
|
|
|
|
|
|
98 |
* @return float|int
|
99 |
*/
|
100 |
public function findExecutionTimeLimit()
|
@@ -117,8 +121,8 @@ trait ResourceTrait
|
|
117 |
$cpuBoundMaxExecutionTime = min($phpMaxExecutionTime, $cpuBoundMaxExecutionTime);
|
118 |
}
|
119 |
|
120 |
-
// Set a max of 30 seconds to avoid NGINX 504 timeouts that are beyond PHP's control, with a minimum of
|
121 |
-
$this->executionTimeLimit = max(min($cpuBoundMaxExecutionTime - static::$executionTimeGapInSeconds, 30),
|
122 |
|
123 |
if ((bool)apply_filters('wpstg.resources.ignoreTimeLimit', false)) {
|
124 |
$this->executionTimeLimit = PHP_INT_MAX;
|
95 |
// TODO Recursion for xDebug? Recursion is bad idea will cause more resource usage, need to avoid it.
|
96 |
|
97 |
/**
|
98 |
+
* Returns the maximum allowed execution time limit.
|
99 |
+
* The minimum needs to be 10seconds!
|
100 |
+
* @see https://github.com/wp-staging/wp-staging-pro/pull/1492
|
101 |
+
*
|
102 |
* @return float|int
|
103 |
*/
|
104 |
public function findExecutionTimeLimit()
|
121 |
$cpuBoundMaxExecutionTime = min($phpMaxExecutionTime, $cpuBoundMaxExecutionTime);
|
122 |
}
|
123 |
|
124 |
+
// Set a max of 30 seconds to avoid NGINX 504 timeouts that are beyond PHP's control, with a minimum of 10 seconds
|
125 |
+
$this->executionTimeLimit = max(min($cpuBoundMaxExecutionTime - static::$executionTimeGapInSeconds, 30), 10);
|
126 |
|
127 |
if ((bool)apply_filters('wpstg.resources.ignoreTimeLimit', false)) {
|
128 |
$this->executionTimeLimit = PHP_INT_MAX;
|
constantsFree.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// WP STAGING version number
|
4 |
if (!defined('WPSTG_VERSION')) {
|
5 |
-
define('WPSTG_VERSION', '2.9.
|
6 |
}
|
7 |
|
8 |
// Compatible up to WordPress Version
|
2 |
|
3 |
// WP STAGING version number
|
4 |
if (!defined('WPSTG_VERSION')) {
|
5 |
+
define('WPSTG_VERSION', '2.9.2');
|
6 |
}
|
7 |
|
8 |
// Compatible up to WordPress Version
|
opcacheBootstrap.php
CHANGED
@@ -45,7 +45,7 @@ if (!$canInvalidate) {
|
|
45 |
*
|
46 |
* We use the "Version" from the headers of the main file of the plugin to compare.
|
47 |
*/
|
48 |
-
$runtimeVersionDifferentFromBuildVersion = get_file_data($pluginFilePath, ['Version' => 'Version'])['Version'] !== '2.9.
|
49 |
$lastCheckHappenedAfterInterval = current_time('timestamp') > (int)get_site_transient('wpstg.bootstrap.opcache.lastCleared') + 5 * MINUTE_IN_SECONDS;
|
50 |
|
51 |
$shouldClearOpCache = apply_filters('wpstg.bootstrap.opcache.shouldClear', $runtimeVersionDifferentFromBuildVersion && $lastCheckHappenedAfterInterval);
|
45 |
*
|
46 |
* We use the "Version" from the headers of the main file of the plugin to compare.
|
47 |
*/
|
48 |
+
$runtimeVersionDifferentFromBuildVersion = get_file_data($pluginFilePath, ['Version' => 'Version'])['Version'] !== '2.9.2';
|
49 |
$lastCheckHappenedAfterInterval = current_time('timestamp') > (int)get_site_transient('wpstg.bootstrap.opcache.lastCleared') + 5 * MINUTE_IN_SECONDS;
|
50 |
|
51 |
$shouldClearOpCache = apply_filters('wpstg.bootstrap.opcache.shouldClear', $runtimeVersionDifferentFromBuildVersion && $lastCheckHappenedAfterInterval);
|
readme.txt
CHANGED
@@ -6,10 +6,10 @@ Contributors: ReneHermi, WP-Staging
|
|
6 |
Donate link: https://wp-staging.com/#pricing
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
-
Tags: backup,
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.8
|
12 |
-
Stable tag: 2.9.
|
13 |
Requires PHP: 5.6
|
14 |
|
15 |
A backup & duplicator plugin - clone, move, duplicate & migrate websites to staging, backup, and development sites for authorized users only.
|
@@ -185,6 +185,9 @@ https://wp-staging.com
|
|
185 |
|
186 |
== Changelog ==
|
187 |
|
|
|
|
|
|
|
188 |
= 2.9.1 =
|
189 |
* New: If cpu load setting is low make use of the file copy limit for pushing / backup process to increase copy speed #1485
|
190 |
* Enh: Add warning notice if WP_CRON_DISABLED is set to true as backup BG Processing depends upon it #1467
|
@@ -203,6 +206,8 @@ https://wp-staging.com
|
|
203 |
* Tweak: Set WordPress 4.4 as minimum required WordPress version #1449
|
204 |
* Dev: Fix Queue working in PHP 8 and Add PHP 8 unit tests in backup fast tests #1450
|
205 |
* Dev: Cancel pending or running github actions backup fast tests if there is a new push on the same PR #1486
|
|
|
|
|
206 |
|
207 |
= 2.9.0 =
|
208 |
* New: Compatible up to WordPress 5.8.2
|
6 |
Donate link: https://wp-staging.com/#pricing
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
Tags: backup, backups, staging, duplication, clone
|
10 |
Requires at least: 3.6+
|
11 |
Tested up to: 5.8
|
12 |
+
Stable tag: 2.9.2
|
13 |
Requires PHP: 5.6
|
14 |
|
15 |
A backup & duplicator plugin - clone, move, duplicate & migrate websites to staging, backup, and development sites for authorized users only.
|
185 |
|
186 |
== Changelog ==
|
187 |
|
188 |
+
= 2.9.2 =
|
189 |
+
* Hotfix: Fix CLONE PUSH BACKUP on Medium and High CPU Load on WP STAGING 2.9.1. Improve Performance of database backup #1492
|
190 |
+
|
191 |
= 2.9.1 =
|
192 |
* New: If cpu load setting is low make use of the file copy limit for pushing / backup process to increase copy speed #1485
|
193 |
* Enh: Add warning notice if WP_CRON_DISABLED is set to true as backup BG Processing depends upon it #1467
|
206 |
* Tweak: Set WordPress 4.4 as minimum required WordPress version #1449
|
207 |
* Dev: Fix Queue working in PHP 8 and Add PHP 8 unit tests in backup fast tests #1450
|
208 |
* Dev: Cancel pending or running github actions backup fast tests if there is a new push on the same PR #1486
|
209 |
+
* Dev: Fix Queue working in PHP 8 and Add PHP 8 unit tests in fast tests #1450
|
210 |
+
* Dev: Cancel pending or running github actions fast tests if there is a new push on the same PR #1486
|
211 |
|
212 |
= 2.9.0 =
|
213 |
* New: Compatible up to WordPress 5.8.2
|
wp-staging.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* Author: WP-STAGING
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi
|
10 |
-
* Version: 2.9.
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|
7 |
* Author: WP-STAGING
|
8 |
* Author URI: https://wp-staging.com
|
9 |
* Contributors: ReneHermi
|
10 |
+
* Version: 2.9.2
|
11 |
* Text Domain: wp-staging
|
12 |
* Domain Path: /languages/
|
13 |
*
|