Ajax
2 years ago
BackgroundProcessing
2 years ago
Dto
2 years ago
Entity
2 years ago
Exceptions
3 years ago
Job
2 years ago
Request
2 years ago
Service
2 years ago
Storage
2 years ago
Task
2 years ago
AfterRestore.php
3 years ago
BackupDeleter.php
3 years ago
BackupDownload.php
3 years ago
BackupProcessLock.php
3 years ago
BackupRepairer.php
3 years ago
BackupScheduler.php
2 years ago
BackupServiceProvider.php
2 years ago
BackupValidator.php
2 years ago
WithBackupIdentifier.php
2 years ago
wpstgBackupHeader.txt
3 years ago
AfterRestore.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPStaging\Backup; |
| 4 | |
| 5 | use WPStaging\Framework\Database\TableService; |
| 6 | use WPStaging\Framework\Security\AccessToken; |
| 7 | use WPStaging\Backup\Ajax\Restore\PrepareRestore; |
| 8 | |
| 9 | class AfterRestore |
| 10 | { |
| 11 | protected $tableService; |
| 12 | protected $accessToken; |
| 13 | |
| 14 | public function __construct(TableService $tableService, AccessToken $accessToken) |
| 15 | { |
| 16 | $this->tableService = $tableService; |
| 17 | $this->accessToken = $accessToken; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @action wp_login |
| 22 | * @see \WPStaging\Backup\BackupServiceProvider::addHooks |
| 23 | */ |
| 24 | public function loginAfterRestore() |
| 25 | { |
| 26 | // Early bail: Not a login after a successful restore |
| 27 | if (get_option('wpstg.restore.justRestored') !== 'yes') { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | // Disable WordPress automatic background updates on this request. |
| 32 | add_filter('automatic_updater_disabled', '__return_false'); |
| 33 | |
| 34 | if (apply_filters('wpstg.backup.import.database.dropOldTablesAfterRestore', true)) { |
| 35 | $this->tableService->deleteTablesStartWith(PrepareRestore::TMP_DATABASE_PREFIX_TO_DROP, [], true); |
| 36 | } |
| 37 | |
| 38 | $this->accessToken->generateNewToken(); |
| 39 | delete_option('wpstg.restore.justRestored'); |
| 40 | delete_option('wpstg.restore.justRestored.metadata'); |
| 41 | } |
| 42 | } |
| 43 |