Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp...
File: restorer.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed');
[2] Fix | Delete
[3] Fix | Delete
if (!class_exists('Updraft_Restorer_Skin')) require_once(UPDRAFTPLUS_DIR.'/includes/updraft-restorer-skin.php');
[4] Fix | Delete
if (!class_exists('UpdraftPlus_Search_Replace')) require_once(UPDRAFTPLUS_DIR.'/includes/class-search-replace.php');
[5] Fix | Delete
[6] Fix | Delete
class Updraft_Restorer {
[7] Fix | Delete
[8] Fix | Delete
// This just stores the result of is_multisite()
[9] Fix | Delete
private $is_multisite;
[10] Fix | Delete
[11] Fix | Delete
// This is just used so far for detecting whether we're on the second run for an entity or not.
[12] Fix | Delete
public $been_restored = array();
[13] Fix | Delete
[14] Fix | Delete
private $tables_been_dropped = array();
[15] Fix | Delete
[16] Fix | Delete
// Public: it is manipulated by the caller after the caller gets the object
[17] Fix | Delete
public $delete = false;
[18] Fix | Delete
[19] Fix | Delete
private $created_by_version = false;
[20] Fix | Delete
[21] Fix | Delete
// This one can be set externally, if the information is available
[22] Fix | Delete
public $ud_backup_is_multisite = -1;
[23] Fix | Delete
[24] Fix | Delete
private $ud_backup_set;
[25] Fix | Delete
[26] Fix | Delete
public $ud_foreign;
[27] Fix | Delete
[28] Fix | Delete
// store restored table names
[29] Fix | Delete
public $restored_table_names = array();
[30] Fix | Delete
[31] Fix | Delete
public $is_dummy_db_restore = false;
[32] Fix | Delete
[33] Fix | Delete
// The default of false means "use the global $wpdb"
[34] Fix | Delete
private $wpdb_obj = false;
[35] Fix | Delete
[36] Fix | Delete
private $line_last_logged = 0;
[37] Fix | Delete
[38] Fix | Delete
private $our_siteurl;
[39] Fix | Delete
[40] Fix | Delete
private $configuration_bundle;
[41] Fix | Delete
[42] Fix | Delete
private $ajax_restore_auth_code;
[43] Fix | Delete
[44] Fix | Delete
private $restore_options;
[45] Fix | Delete
[46] Fix | Delete
private $restore_this_site = array();
[47] Fix | Delete
[48] Fix | Delete
private $restore_this_table = array();
[49] Fix | Delete
[50] Fix | Delete
private $restoring_table = '';
[51] Fix | Delete
[52] Fix | Delete
private $line = 0;
[53] Fix | Delete
[54] Fix | Delete
private $statements_run = 0;
[55] Fix | Delete
[56] Fix | Delete
private $use_wpdb = null;
[57] Fix | Delete
[58] Fix | Delete
private $import_table_prefix = null;
[59] Fix | Delete
[60] Fix | Delete
private $final_import_table_prefix = null;
[61] Fix | Delete
[62] Fix | Delete
private $disable_atomic_on_current_table = false;
[63] Fix | Delete
[64] Fix | Delete
private $table_engine = '';
[65] Fix | Delete
[66] Fix | Delete
private $table_name = '';
[67] Fix | Delete
[68] Fix | Delete
private $continuation_data;
[69] Fix | Delete
[70] Fix | Delete
private $current_index = 0;
[71] Fix | Delete
[72] Fix | Delete
private $current_type = '';
[73] Fix | Delete
[74] Fix | Delete
private $previous_table_name = '';
[75] Fix | Delete
[76] Fix | Delete
private $include_unspecified_tables = false;
[77] Fix | Delete
[78] Fix | Delete
private $tables_to_restore = array();
[79] Fix | Delete
[80] Fix | Delete
private $stored_routine_supported = null;
[81] Fix | Delete
[82] Fix | Delete
private $tables_to_skip = array();
[83] Fix | Delete
[84] Fix | Delete
public $search_replace_obj = null;
[85] Fix | Delete
[86] Fix | Delete
// Constants for use with the move_backup_in method
[87] Fix | Delete
// These can't be arbitrarily changed; there is legacy code doing bitwise operations and numerical comparisons, and possibly legacy code still using the values directly.
[88] Fix | Delete
const MOVEIN_OVERWRITE_NO_BACKUP = 0;
[89] Fix | Delete
const MOVEIN_MAKE_BACKUP_OF_EXISTING = 1;
[90] Fix | Delete
const MOVEIN_DO_NOTHING_IF_EXISTING = 2;
[91] Fix | Delete
const MOVEIN_COPY_IN_CONTENTS = 3;
[92] Fix | Delete
[93] Fix | Delete
private $wp_upgrader;
[94] Fix | Delete
[95] Fix | Delete
public $skin = null;
[96] Fix | Delete
[97] Fix | Delete
public $strings = array();
[98] Fix | Delete
[99] Fix | Delete
private $generated_columns = array();
[100] Fix | Delete
[101] Fix | Delete
private $supported_generated_column_engines = array();
[102] Fix | Delete
[103] Fix | Delete
private $generated_columns_exist_in_the_statement = array();
[104] Fix | Delete
[105] Fix | Delete
private $printed_new_table_prefix = false;
[106] Fix | Delete
[107] Fix | Delete
private $old_table_prefix = null;
[108] Fix | Delete
[109] Fix | Delete
private $old_abspath = '';
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Constructor
[113] Fix | Delete
*
[114] Fix | Delete
* @param WP_Upgrader_Skin|Null $skin - an upgrader skin
[115] Fix | Delete
* @param Array|Null $backup_set - the backup set to restore
[116] Fix | Delete
* @param Boolean $short_init - whether just to do a minimal initialisation
[117] Fix | Delete
* @param Array $restore_options - options to guide the restoration
[118] Fix | Delete
* @param Array|Null $continuation_data - continuation data; the jobdata of the job thus far (but only a few properties are used - including second_loop_entities; $restore_options will have come from there too if relevant, but that is passed in here separately); the 'last_index_*' entries also indicate unzipping progress
[119] Fix | Delete
*/
[120] Fix | Delete
public function __construct($skin = null, $backup_set = null, $short_init = false, $restore_options = array(), $continuation_data = null) {
[121] Fix | Delete
[122] Fix | Delete
$this->our_siteurl = untrailingslashit(site_url());
[123] Fix | Delete
[124] Fix | Delete
$this->continuation_data = $continuation_data;
[125] Fix | Delete
[126] Fix | Delete
$this->setup_database_objects();
[127] Fix | Delete
[128] Fix | Delete
$this->search_replace_obj = new UpdraftPlus_Search_Replace();
[129] Fix | Delete
[130] Fix | Delete
if ($short_init) return;
[131] Fix | Delete
[132] Fix | Delete
// If updraft_incremental_restore_point is equal to -1 then this is either not a incremental restore or we are going to restore up to the latest increment, so there is no need to prune the backup set of any unwanted backup archives.
[133] Fix | Delete
if (isset($restore_options['updraft_incremental_restore_point']) && $restore_options['updraft_incremental_restore_point'] > 0) {
[134] Fix | Delete
$restore_point = $restore_options['updraft_incremental_restore_point'];
[135] Fix | Delete
foreach ($backup_set['incremental_sets'] as $increment_timestamp => $entities) {
[136] Fix | Delete
if ($increment_timestamp > $restore_point) {
[137] Fix | Delete
foreach ($entities as $entity => $backups) {
[138] Fix | Delete
foreach ($backups as $key => $value) {
[139] Fix | Delete
unset($backup_set[$entity][$key]);
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
// if updraft_include_more_path is set then, the user has chosen where they want these backup files to be restored as either UD did not know where to restore them or the original location is not found on disk any more
[147] Fix | Delete
if (isset($restore_options['updraft_include_more_path'])) {
[148] Fix | Delete
if (!isset($backup_set['morefiles_linked_indexes']) || !isset($backup_set['morefiles_more_locations'])) {
[149] Fix | Delete
$backup_set['morefiles_more_locations'] = $restore_options['updraft_include_more_path'];
[150] Fix | Delete
foreach ($restore_options['updraft_include_more_path'] as $key => $path) {
[151] Fix | Delete
$backup_set['morefiles_linked_indexes'][] = $key;
[152] Fix | Delete
}
[153] Fix | Delete
} else {
[154] Fix | Delete
foreach ($restore_options['updraft_include_more_path'] as $key => $path) {
[155] Fix | Delete
$backup_set['morefiles_more_locations'][$key] = $path;
[156] Fix | Delete
}
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if (isset($restore_options['updraft_include_more_index'])) {
[160] Fix | Delete
// unset any backups the user has chosen not to restore
[161] Fix | Delete
foreach (array_keys($backup_set['more']) as $key) {
[162] Fix | Delete
if (!in_array($key, $restore_options['updraft_include_more_index'])) unset($backup_set['more'][$key]);
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
if (isset($restore_options['include_unspecified_tables'])) $this->include_unspecified_tables = $restore_options['include_unspecified_tables'];
[168] Fix | Delete
if (isset($restore_options['tables_to_restore'])) $this->tables_to_restore = $restore_options['tables_to_restore'];
[169] Fix | Delete
if (isset($restore_options['tables_to_skip'])) $this->tables_to_skip = $restore_options['tables_to_skip'];
[170] Fix | Delete
[171] Fix | Delete
// Restore in the most helpful order
[172] Fix | Delete
uksort($backup_set, array('UpdraftPlus_Manipulation_Functions', 'sort_restoration_entities'));
[173] Fix | Delete
[174] Fix | Delete
$this->ud_backup_set = $backup_set;
[175] Fix | Delete
[176] Fix | Delete
add_filter('updraftplus_logline', array($this, 'updraftplus_logline'), 10, 5);
[177] Fix | Delete
add_action('updraftplus_restored_db_table', array($this, 'updraftplus_restored_db_table'), 10, 3);
[178] Fix | Delete
[179] Fix | Delete
do_action('updraftplus_restorer_restore_options', $restore_options);
[180] Fix | Delete
$this->ud_multisite_selective_restore = (is_array($restore_options) && !empty($restore_options['updraft_restore_ms_whichsites']) && $restore_options['updraft_restore_ms_whichsites'] > 0) ? $restore_options['updraft_restore_ms_whichsites'] : false;
[181] Fix | Delete
$this->restore_options = $restore_options;
[182] Fix | Delete
[183] Fix | Delete
$this->ud_foreign = empty($backup_set['meta_foreign']) ? false : $backup_set['meta_foreign'];
[184] Fix | Delete
if (isset($backup_set['is_multisite'])) $this->ud_backup_is_multisite = $backup_set['is_multisite'];
[185] Fix | Delete
if (isset($backup_set['created_by_version'])) $this->created_by_version = $backup_set['created_by_version'];
[186] Fix | Delete
[187] Fix | Delete
$this->backup_strings();
[188] Fix | Delete
[189] Fix | Delete
$this->is_multisite = is_multisite();
[190] Fix | Delete
[191] Fix | Delete
require_once(UPDRAFTPLUS_DIR.'/includes/class-database-utility.php');
[192] Fix | Delete
[193] Fix | Delete
if (!class_exists('WP_Upgrader')) include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php');
[194] Fix | Delete
$this->skin = $skin;
[195] Fix | Delete
$this->wp_upgrader = new WP_Upgrader($skin);
[196] Fix | Delete
$this->wp_upgrader->init();
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
/**
[200] Fix | Delete
* This function will check if we are using wpdb, if we are not then it will setup our wpdb-like objects
[201] Fix | Delete
*
[202] Fix | Delete
* @param boolean $reconnect_wpdb - if we should include and create a new instance of wpdb
[203] Fix | Delete
*
[204] Fix | Delete
* @return void
[205] Fix | Delete
*/
[206] Fix | Delete
private function setup_database_objects($reconnect_wpdb = false) {
[207] Fix | Delete
global $wpdb;
[208] Fix | Delete
[209] Fix | Delete
if ($reconnect_wpdb) {
[210] Fix | Delete
$wpdb->db_connect(true);
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
// Line up a wpdb-like object
[214] Fix | Delete
if (!$this->use_wpdb()) {
[215] Fix | Delete
// We have our own extension which drops lots of the overhead on the query
[216] Fix | Delete
$wpdb_obj = new UpdraftPlus_WPDB(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
[217] Fix | Delete
// Was that successful?
[218] Fix | Delete
if (!$wpdb_obj->is_mysql || !$wpdb_obj->ready) {
[219] Fix | Delete
$this->use_wpdb = true;
[220] Fix | Delete
} else {
[221] Fix | Delete
$this->wpdb_obj = $wpdb_obj;
[222] Fix | Delete
$this->mysql_dbh = $wpdb_obj->updraftplus_get_database_handle();
[223] Fix | Delete
$this->use_mysqli = $wpdb_obj->updraftplus_use_mysqli();
[224] Fix | Delete
}
[225] Fix | Delete
}
[226] Fix | Delete
}
[227] Fix | Delete
[228] Fix | Delete
/**
[229] Fix | Delete
* This function will try to restore the database connection, if it succeeds then it returns true otherwise false
[230] Fix | Delete
*
[231] Fix | Delete
* @return boolean - true if the connection is restored, otherwise false
[232] Fix | Delete
*/
[233] Fix | Delete
private function restore_database_connection() {
[234] Fix | Delete
global $updraftplus, $wpdb;
[235] Fix | Delete
[236] Fix | Delete
$wpdb_connected = $updraftplus->check_db_connection($wpdb, false, false, true);
[237] Fix | Delete
[238] Fix | Delete
if (false === $wpdb_connected || -1 === $wpdb_connected) {
[239] Fix | Delete
sleep(10);
[240] Fix | Delete
$this->setup_database_objects(true);
[241] Fix | Delete
return false;
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
return true;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
/**
[248] Fix | Delete
* Get the wpdb-like object that we are using, if we are using one
[249] Fix | Delete
*
[250] Fix | Delete
* @return UpdraftPlus_WPDB|Boolean
[251] Fix | Delete
*/
[252] Fix | Delete
public function get_db_object() {
[253] Fix | Delete
return $this->wpdb_obj;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Restore has been completed - clean some things up
[258] Fix | Delete
*
[259] Fix | Delete
* @param Boolean|WP_Error $successful - if the restore was successful (true) or not (false or WP_Error). If not, then only a minimum of necessary clean-up things is done.
[260] Fix | Delete
* @param Boolean $browser_context - if true, then extra messages will be echo-ed
[261] Fix | Delete
*
[262] Fix | Delete
* @uses UpdraftPlus::log()
[263] Fix | Delete
*/
[264] Fix | Delete
public function post_restore_clean_up($successful = true, $browser_context = true) {
[265] Fix | Delete
[266] Fix | Delete
global $updraftplus, $updraftplus_admin;
[267] Fix | Delete
[268] Fix | Delete
$updraftplus->log_restore_update(array('type' => 'state', 'stage' => 'cleaning', 'data' => array()));
[269] Fix | Delete
[270] Fix | Delete
if (is_wp_error($successful)) {
[271] Fix | Delete
foreach ($successful->get_error_codes() as $code) {
[272] Fix | Delete
if ('already_exists' == $code) {
[273] Fix | Delete
if ($browser_context) {
[274] Fix | Delete
global $updraftplus_admin;
[275] Fix | Delete
$updraftplus_admin->print_delete_old_dirs_form(false);
[276] Fix | Delete
} else {
[277] Fix | Delete
$updraftplus->log(__('Your WordPress install has old directories from its state before you restored/migrated (technical information: these are suffixed with -old).', 'updraftplus'));
[278] Fix | Delete
}
[279] Fix | Delete
}
[280] Fix | Delete
$data = $successful->get_error_data($code);
[281] Fix | Delete
if (!empty($data)) {
[282] Fix | Delete
$pdata = is_string($data) ? $data : serialize($data);
[283] Fix | Delete
$updraftplus->log(__('Error data:', 'updraftplus').' '.$pdata, 'warning-restore');
[284] Fix | Delete
if (false !== strpos($pdata, 'PCLZIP_ERR_BAD_FORMAT (-10)')) {
[285] Fix | Delete
$url = apply_filters('updraftplus_com_link', 'https://updraftplus.com/faqs/error-message-pclzip_err_bad_format-10-invalid-archive-structure-mean/');
[286] Fix | Delete
if ($browser_context) {
[287] Fix | Delete
echo '<a href="'.$url.'" target="_blank"><strong>'.__('Follow this link for more information', 'updraftplus').'</strong></a><br>';
[288] Fix | Delete
} else {
[289] Fix | Delete
$updraftplus->log(__('Follow this link for more information', 'updraftplus').': '.$url);
[290] Fix | Delete
}
[291] Fix | Delete
}
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
}
[295] Fix | Delete
$successful = false;
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
// From this point on, $successful is a boolean
[299] Fix | Delete
if ($successful) {
[300] Fix | Delete
// All done - remove the intermediate marker
[301] Fix | Delete
delete_site_option('updraft_restore_in_progress');
[302] Fix | Delete
[303] Fix | Delete
foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
[304] Fix | Delete
add_filter('pre_option_'.$opt, array($this, 'option_filter_'.$opt));
[305] Fix | Delete
}
[306] Fix | Delete
[307] Fix | Delete
// Clear any cached pages after the restore
[308] Fix | Delete
$this->clear_caches();
[309] Fix | Delete
[310] Fix | Delete
// Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system
[311] Fix | Delete
$template = get_option('template');
[312] Fix | Delete
if (!empty($template) && WP_DEFAULT_THEME != $template && strtolower($template) != $template) {
[313] Fix | Delete
[314] Fix | Delete
$theme_root = get_theme_root($template);
[315] Fix | Delete
[316] Fix | Delete
if (!file_exists("$theme_root/$template/style.css") && file_exists("$theme_root/".strtolower($template)."/style.css")) {
[317] Fix | Delete
$updraftplus->log_e("Theme directory (%s) not found, but lower-case version exists; updating database option accordingly", $template);
[318] Fix | Delete
update_option('template', strtolower($template));
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
if (!function_exists('validate_current_theme')) include_once(ABSPATH.WPINC.'/themes');
[324] Fix | Delete
[325] Fix | Delete
if (!validate_current_theme()) {
[326] Fix | Delete
if ($browser_context) echo '<strong>';
[327] Fix | Delete
$updraftplus->log_e("The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme");
[328] Fix | Delete
if ($browser_context) echo '</strong>';
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
do_action('updraftplus_restore_completed');
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
if ($browser_context) echo '</div>'; // Close the updraft_restore_progress div
[335] Fix | Delete
[336] Fix | Delete
restore_error_handler();
[337] Fix | Delete
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
/**
[341] Fix | Delete
* Whether or not we must use the global $wpdb object for database queries.
[342] Fix | Delete
* That is to say: we *can* always use it. But we prefer to avoid the overhead since we are potentially doing very many queries.
[343] Fix | Delete
*
[344] Fix | Delete
* This is the getter. We have no use-case for a setter outside of this class, so we just set it directly.
[345] Fix | Delete
*
[346] Fix | Delete
* @return Boolean
[347] Fix | Delete
*/
[348] Fix | Delete
public function use_wpdb() {
[349] Fix | Delete
if (!is_bool($this->use_wpdb)) {
[350] Fix | Delete
global $wpdb;
[351] Fix | Delete
if (defined('UPDRAFTPLUS_USE_WPDB')) {
[352] Fix | Delete
$this->use_wpdb = (bool) UPDRAFTPLUS_USE_WPDB;
[353] Fix | Delete
} else {
[354] Fix | Delete
$this->use_wpdb = ((!function_exists('mysql_query') && !function_exists('mysqli_query')) || !$wpdb->is_mysql || !$wpdb->ready) ? true : false;
[355] Fix | Delete
}
[356] Fix | Delete
}
[357] Fix | Delete
return $this->use_wpdb;
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
/**
[361] Fix | Delete
* Get the skin
[362] Fix | Delete
*
[363] Fix | Delete
* @return WP_Upgrader_Skin
[364] Fix | Delete
*/
[365] Fix | Delete
public function ud_get_skin() {
[366] Fix | Delete
return $this->skin;
[367] Fix | Delete
}
[368] Fix | Delete
[369] Fix | Delete
/**
[370] Fix | Delete
* Ensure that needed files are present locally, and return data for the next step (plus do some internal configuration)
[371] Fix | Delete
*
[372] Fix | Delete
* @param Array $entities_to_restore - as returned by self::get_entities_to_restore()
[373] Fix | Delete
* @param Array $backupable_entities - list of entities that can be backed u
[374] Fix | Delete
* @param Array $services - list of services that the backup can be found at
[375] Fix | Delete
*
[376] Fix | Delete
* @uses self::pre_restore_backup() (and some other internal properties)
[377] Fix | Delete
* @uses UpdraftPlus::log()
[378] Fix | Delete
*
[379] Fix | Delete
* @return Boolean|Array|WP_Error - a sorted array (of entity types and files for each entity type) or false or a WP_Error if there was an error
[380] Fix | Delete
*/
[381] Fix | Delete
private function ensure_restore_files_present($entities_to_restore, $backupable_entities, $services) {
[382] Fix | Delete
[383] Fix | Delete
global $updraftplus;
[384] Fix | Delete
[385] Fix | Delete
$entities_to_download = $this->get_entities_to_download($entities_to_restore);
[386] Fix | Delete
[387] Fix | Delete
$backup_set = $this->ud_backup_set;
[388] Fix | Delete
$timestamp = $backup_set['timestamp'];
[389] Fix | Delete
$second_loop = array();
[390] Fix | Delete
[391] Fix | Delete
$updraft_dir = $updraftplus->backups_dir_location();
[392] Fix | Delete
$foreign_known = apply_filters('updraftplus_accept_archivename', array());
[393] Fix | Delete
[394] Fix | Delete
// First loop: make sure that files are present + readable; and populate array for second loop
[395] Fix | Delete
foreach ($backup_set as $type => $files) {
[396] Fix | Delete
[397] Fix | Delete
// All restorable entities must be given explicitly, as we can store other arbitrary data in the history array
[398] Fix | Delete
if (!isset($backupable_entities[$type]) && 'db' != $type) continue;
[399] Fix | Delete
[400] Fix | Delete
if (isset($backupable_entities[$type]['restorable']) && false == $backupable_entities[$type]['restorable']) continue;
[401] Fix | Delete
[402] Fix | Delete
if (!isset($entities_to_download[$type])) continue;
[403] Fix | Delete
[404] Fix | Delete
if ('wpcore' == $type && is_multisite() && 0 === $this->ud_backup_is_multisite) {
[405] Fix | Delete
$updraftplus->log('wpcore: '.__('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus'), 'notice-restore');
[406] Fix | Delete
// TODO
[407] Fix | Delete
// $updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.');
[408] Fix | Delete
continue;
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
if (is_string($files)) $files = array($files);
[412] Fix | Delete
[413] Fix | Delete
foreach ($files as $ind => $file) {
[414] Fix | Delete
[415] Fix | Delete
$fullpath = $updraft_dir.'/'.$file;
[416] Fix | Delete
$updraftplus->log(sprintf(__("Looking for %s archive: file name: %s", 'updraftplus'), $type, $file), 'notice-restore');
[417] Fix | Delete
[418] Fix | Delete
if (is_array($this->continuation_data) && isset($this->continuation_data['second_loop_entities'][$type]) && !in_array($file, $this->continuation_data['second_loop_entities'][$type])) {
[419] Fix | Delete
$updraftplus->log(__('Skipping: this archive was already restored.', 'updraftplus'), 'notice-restore');
[420] Fix | Delete
// Set the marker so that the existing directory isn't moved out of the way
[421] Fix | Delete
$this->been_restored[$type] = true;
[422] Fix | Delete
continue;
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
if (!is_readable($fullpath) || 0 == filesize($fullpath)) UpdraftPlus_Storage_Methods_Interface::get_remote_file($services, $file, $timestamp, true);
[426] Fix | Delete
[427] Fix | Delete
$index = (0 == $ind) ? '' : $ind;
[428] Fix | Delete
// If a file size is stored in the backup data, then verify correctness of the local file
[429] Fix | Delete
if (isset($backup_set[$type.$index.'-size'])) {
[430] Fix | Delete
$fs = $backup_set[$type.$index.'-size'];
[431] Fix | Delete
$print_message = __("Archive is expected to be size:", 'updraftplus')." ".round($fs/1024, 1)." KB: ";
[432] Fix | Delete
$as = @filesize($fullpath);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
[433] Fix | Delete
if ($as == $fs) {
[434] Fix | Delete
$updraftplus->log($print_message.__('OK', 'updraftplus'), 'notice-restore');
[435] Fix | Delete
} else {
[436] Fix | Delete
$updraftplus->log($print_message.__('Error:', 'updraftplus')." ".__('file is size:', 'updraftplus')." ".round($as/1024)." ($fs, $as)", 'warning-restore');
[437] Fix | Delete
}
[438] Fix | Delete
} else {
[439] Fix | Delete
$updraftplus->log(__("The backup records do not contain information about the proper size of this file.", 'updraftplus'), 'notice-restore');
[440] Fix | Delete
}
[441] Fix | Delete
if (!is_readable($fullpath)) {
[442] Fix | Delete
$updraftplus->log(__('Could not read one of the files for restoration', 'updraftplus')." ($file)", 'warning-restore');
[443] Fix | Delete
$updraftplus->log("$file: ".__('Could not read one of the files for restoration', 'updraftplus'), 'error');
[444] Fix | Delete
return false;
[445] Fix | Delete
}
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
if (empty($this->ud_foreign)) {
[449] Fix | Delete
$types = array($type);
[450] Fix | Delete
} else {
[451] Fix | Delete
if ('db' != $type || empty($foreign_known[$this->ud_foreign]['separatedb'])) {
[452] Fix | Delete
$types = array('wpcore');
[453] Fix | Delete
} else {
[454] Fix | Delete
$types = array('db');
[455] Fix | Delete
}
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
foreach ($types as $check_type) {
[459] Fix | Delete
$info = isset($backupable_entities[$check_type]) ? $backupable_entities[$check_type] : array();
[460] Fix | Delete
$val = $this->pre_restore_backup($files, $check_type, $info);
[461] Fix | Delete
if (is_wp_error($val)) {
[462] Fix | Delete
$updraftplus->log_wp_error($val);
[463] Fix | Delete
foreach ($val->get_error_messages() as $msg) {
[464] Fix | Delete
$updraftplus->log(__('Error:', 'updraftplus').' '.$msg, 'warning-restore');
[465] Fix | Delete
}
[466] Fix | Delete
return $val;
[467] Fix | Delete
} elseif (false === $val) {
[468] Fix | Delete
return false;
[469] Fix | Delete
}
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
foreach ($entities_to_restore as $entity => $via) {
[473] Fix | Delete
if ($via == $type) {
[474] Fix | Delete
if ('wpcore' == $via && 'db' == $entity && count($files) > 1) {
[475] Fix | Delete
$second_loop[$entity] = apply_filters('updraftplus_select_wpcore_file_with_db', $files, $this->ud_foreign);
[476] Fix | Delete
} else {
[477] Fix | Delete
$second_loop[$entity] = $files;
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
$this->delete = UpdraftPlus_Options::get_updraft_option('updraft_delete_local', 1) ? true : false;
[485] Fix | Delete
if (empty($services) || array('email') === $services || !empty($this->ud_foreign)) {
[486] Fix | Delete
if ($this->delete) $updraftplus->log_e('Will not delete any archives after unpacking them, because there was no cloud storage for this backup');
[487] Fix | Delete
$this->delete = false;
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
if (!empty($this->ud_foreign)) $updraftplus->log("Foreign backup; created by: ".$this->ud_foreign);
[491] Fix | Delete
[492] Fix | Delete
// Second loop: now actually do the restoration
[493] Fix | Delete
uksort($second_loop, array('UpdraftPlus_Manipulation_Functions', 'sort_restoration_entities'));
[494] Fix | Delete
[495] Fix | Delete
// If continuing, then prune those already done
[496] Fix | Delete
if (is_array($this->continuation_data) && isset($this->continuation_data['second_loop_entities'])) {
[497] Fix | Delete
foreach ($second_loop as $type => $files) {
[498] Fix | Delete
if (isset($this->continuation_data['second_loop_entities'][$type])) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function