PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.1
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.1
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 / Staging / Service / LegacyOptionsCache.php
wp-staging / Staging / Service Last commit date
Database 1 week ago AbstractStagingSetup.php 1 week ago DirectoryScanner.php 1 week ago FileCopier.php 1 week ago LegacyOptionsCache.php 1 week ago StagingEngine.php 1 week ago StagingSetup.php 1 week ago TableScanner.php 1 week ago
LegacyOptionsCache.php
65 lines
1 <?php
2
3 namespace WPStaging\Staging\Service;
4
5 use stdClass;
6 use WPStaging\Backend\Modules\Jobs\Job;
7 use WPStaging\Core\WPStaging;
8 use WPStaging\Framework\Utils\Cache\Cache;
9 use WPStaging\Staging\Sites;
10
11
12
13
14 class LegacyOptionsCache
15 {
16 public function prepare(string $mainJob, string $cloneId = '')
17 {
18 if (WPStaging::make(StagingEngine::class)->getEngine() !== StagingEngine::ENGINE_LEGACY) {
19 return;
20 }
21
22 $cloneOptionCache = WPStaging::make(Cache::class);
23 $cloneOptionCache->setLifetime(-1);
24 $cloneOptionCache->setPath(WPStaging::getContentDir());
25 $cloneOptionCache->setFileName(Job::CLONE_OPTIONS_KEY);
26
27 $filesIndexCache = WPStaging::make(Cache::class);
28 $filesIndexCache->setLifetime(-1);
29 $filesIndexCache->setPath(WPStaging::getContentDir());
30 $filesIndexCache->setFileName(Job::FILES_INDEX_KEY);
31 $filesIndexCache->delete();
32
33 $existingClones = get_option(Sites::STAGING_SITES_OPTION, []);
34 $existingClones = is_array($existingClones) ? $existingClones : [];
35 $currentCloneId = isset($existingClones[$cloneId]) ? $cloneId : null;
36
37 $options = new stdClass();
38 $options->root = str_replace(["\\", '/'], DIRECTORY_SEPARATOR, ABSPATH);
39 $options->current = $currentCloneId;
40 $options->clone = $cloneId;
41 $options->currentClone = $currentCloneId !== null ? $existingClones[$cloneId] : null;
42 $options->existingClones = $existingClones;
43
44 $options->clonedTables = [];
45
46 $options->totalFiles = 0;
47 $options->totalFileSize = 0;
48 $options->copiedFiles = 0;
49
50 $options->includedDirectories = [];
51 $options->includedExtraDirectories = [];
52 $options->excludedDirectories = [];
53 $options->extraDirectories = [];
54 $options->scannedDirectories = [];
55
56 $options->currentJob = $mainJob === Job::PUSH ? '' : 'PreserveDataFirstStep';
57 $options->currentStep = 0;
58 $options->totalSteps = 0;
59 $options->mainJob = $mainJob;
60 $options->stagingEngine = StagingEngine::ENGINE_LEGACY;
61
62 $cloneOptionCache->save($options);
63 }
64 }
65