Migration, Backup, Staging – WPvivid - Version 0.9.44

Version Description

  • Successfully tested with WordPress 5.5.
  • Fixed: Refreshing Google Drive token failed in some cases.
Download this release

Release Info

Developer wpvivid
Plugin Icon 128x128 Migration, Backup, Staging – WPvivid
Version 0.9.44
Comparing to
See all releases

Code changes from version 0.9.43 to 0.9.44

admin/class-wpvivid-admin.php CHANGED
@@ -211,6 +211,12 @@ class WPvivid_Admin {
211
  'remotealias' => __('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore'),
212
  'remoteexist' => __('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore'),
213
  'backup_calc_timeout' => __('Calculating the size of files, folder and database timed out. If you continue to receive this error, please go to the plugin settings, uncheck \'Calculate the size of files, folder and database before backing up\', save changes, then try again.', 'wpvivid-backuprestore'),
 
 
 
 
 
 
214
  ));
215
 
216
  wp_enqueue_script('plupload-all');
211
  'remotealias' => __('Warning: An alias for remote storage is required.', 'wpvivid-backuprestore'),
212
  'remoteexist' => __('Warning: The alias already exists in storage list.', 'wpvivid-backuprestore'),
213
  'backup_calc_timeout' => __('Calculating the size of files, folder and database timed out. If you continue to receive this error, please go to the plugin settings, uncheck \'Calculate the size of files, folder and database before backing up\', save changes, then try again.', 'wpvivid-backuprestore'),
214
+ 'restore_step1' => __('Step One: In the backup list, click the \'Restore\' button on the backup you want to restore. This will bring up the restore tab', 'wpvivid-backuprestore'),
215
+ 'restore_step2' => __('Step Two: Choose an option to complete restore, if any', 'wpvivid-backuprestore'),
216
+ 'restore_step3' => __('Step Three: Click \'Restore\' button', 'wpvivid-backuprestore'),
217
+ 'get_key_step1' => __('1. Visit Key tab page of WPvivid backup plugin of destination site.', 'wpvivid-backuprestore'),
218
+ 'get_key_step2' => __('2. Generate a key by clicking Generate button and copy it.', 'wpvivid-backuprestore'),
219
+ 'get_key_step3' => __('3. Go back to this page and paste the key in key box below. Lastly, click Save button.', 'wpvivid-backuprestore'),
220
  ));
221
 
222
  wp_enqueue_script('plupload-all');
admin/partials/wpvivid-backup-restore-page-display.php CHANGED
@@ -839,9 +839,9 @@ function wpvivid_backuppage_add_page_backup(){
839
  var top = jQuery('#wpvivid_how_to_restore_backup_describe').offset().top-jQuery('#wpvivid_how_to_restore_backup_describe').height();
840
  jQuery('html, body').animate({scrollTop:top}, 'slow');
841
  var div = "<div class='notice notice-info is-dismissible inline'>" +
842
- "<p><?php _e('Step One: In the backup list, click the \'Restore\' button on the backup you want to restore. This will bring up the restore tab', 'wpvivid-backuprestore'); ?></p>" +
843
- "<p><?php _e('Step Two: Choose an option to complete restore, if any', 'wpvivid-backuprestore'); ?></p>" +
844
- "<p><?php _e('Step Three: Click \'Restore\' button', 'wpvivid-backuprestore'); ?></p>" +
845
  "<button type='button' class='notice-dismiss' onclick='click_dismiss_restore_notice(this);'>" +
846
  "<span class='screen-reader-text'>Dismiss this notice.</span>" +
847
  "</button>" +
839
  var top = jQuery('#wpvivid_how_to_restore_backup_describe').offset().top-jQuery('#wpvivid_how_to_restore_backup_describe').height();
840
  jQuery('html, body').animate({scrollTop:top}, 'slow');
841
  var div = "<div class='notice notice-info is-dismissible inline'>" +
842
+ "<p>" + wpvividlion.restore_step1 + "</p>" +
843
+ "<p>" + wpvividlion.restore_step2 + "</p>" +
844
+ "<p>" + wpvividlion.restore_step3 + "</p>" +
845
  "<button type='button' class='notice-dismiss' onclick='click_dismiss_restore_notice(this);'>" +
846
  "<span class='screen-reader-text'>Dismiss this notice.</span>" +
847
  "</button>" +
includes/class-wpvivid-function-realize.php CHANGED
@@ -14,15 +14,45 @@ class WPvivid_Function_Realize
14
  $tasks = WPvivid_taskmanager::get_tasks();
15
  foreach ($tasks as $task){
16
  $task_id = $task['id'];
17
- $file_name = WPvivid_taskmanager::get_task_options($task_id, 'file_prefix');
18
- $backup_options = WPvivid_taskmanager::get_task_options($task_id, 'backup_options');
19
- $file = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $backup_options['dir'] . DIRECTORY_SEPARATOR . $file_name . '_cancel';
20
- touch($file);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- $timestamp = wp_next_scheduled(WPVIVID_TASK_MONITOR_EVENT, array($task_id));
23
 
24
- if ($timestamp === false) {
25
- $wpvivid_plugin->add_monitor_event($task_id, 10);
 
26
  }
27
  }
28
 
14
  $tasks = WPvivid_taskmanager::get_tasks();
15
  foreach ($tasks as $task){
16
  $task_id = $task['id'];
17
+ $status=WPvivid_taskmanager::get_backup_task_status($task_id);
18
+ $time_spend=$status['run_time']-$status['start_time'];
19
+ $options=WPvivid_Setting::get_option('wpvivid_common_setting');
20
+ if(isset($options['max_execution_time']))
21
+ {
22
+ $limit=$options['max_execution_time'];
23
+ }
24
+ else
25
+ {
26
+ $limit=WPVIVID_MAX_EXECUTION_TIME;
27
+ }
28
+ if($time_spend > $limit * 2){
29
+ $file_name = WPvivid_taskmanager::get_task_options($task_id, 'file_prefix');
30
+ $backup_options = WPvivid_taskmanager::get_task_options($task_id, 'backup_options');
31
+ $file = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $backup_options['dir'] . DIRECTORY_SEPARATOR . $file_name . '_cancel';
32
+ touch($file);
33
+
34
+ if($wpvivid_plugin->wpvivid_log->log_file_handle==false)
35
+ {
36
+ $wpvivid_plugin->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name'));
37
+ }
38
+ $wpvivid_plugin->wpvivid_log->WriteLog('Backup cancelled. Twice the setting time.','notice');
39
+ $task=new WPvivid_Backup_Task($task_id);
40
+ $task->update_status('cancel');
41
+ $wpvivid_plugin->clean_backing_up_data_event($task_id);
42
+ WPvivid_Schedule::clear_monitor_schedule($task_id);
43
+ WPvivid_taskmanager::delete_task($task_id);
44
+ }
45
+ else {
46
+ $file_name = WPvivid_taskmanager::get_task_options($task_id, 'file_prefix');
47
+ $backup_options = WPvivid_taskmanager::get_task_options($task_id, 'backup_options');
48
+ $file = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $backup_options['dir'] . DIRECTORY_SEPARATOR . $file_name . '_cancel';
49
+ touch($file);
50
 
51
+ $timestamp = wp_next_scheduled(WPVIVID_TASK_MONITOR_EVENT, array($task_id));
52
 
53
+ if ($timestamp === false) {
54
+ $wpvivid_plugin->add_monitor_event($task_id, 10);
55
+ }
56
  }
57
  }
58
 
includes/class-wpvivid-migrate.php CHANGED
@@ -967,9 +967,9 @@ class WPvivid_Migrate
967
  if(!wpvivid_display_get_key) {
968
  wpvivid_display_get_key = true;
969
  var div = "<div class=\'notice notice-info is-dismissible inline\'>" +
970
- "<p>'.__('1. Visit Key tab page of WPvivid backup plugin of destination site.', 'wpvivid-backuprestore').'</p>" +
971
- "<p>'.__('2. Generate a key by clicking Generate button and copy it.', 'wpvivid-backuprestore').'</p>" +
972
- "<p>'.__('3. Go back to this page and paste the key in key box below. Lastly, click Save button.', 'wpvivid-backuprestore').'</p>" +
973
  "<button type=\'button\' class=\'notice-dismiss\' onclick=\'click_dismiss_key_notice(this);\'>" +
974
  "<span class=\'screen-reader-text\'>Dismiss this notice.</span>" +
975
  "</button>" +
967
  if(!wpvivid_display_get_key) {
968
  wpvivid_display_get_key = true;
969
  var div = "<div class=\'notice notice-info is-dismissible inline\'>" +
970
+ "<p>" + wpvividlion.get_key_step1 + "</p>" +
971
+ "<p>" + wpvividlion.get_key_step2 + "</p>" +
972
+ "<p>" + wpvividlion.get_key_step3 + "</p>" +
973
  "<button type=\'button\' class=\'notice-dismiss\' onclick=\'click_dismiss_key_notice(this);\'>" +
974
  "<span class=\'screen-reader-text\'>Dismiss this notice.</span>" +
975
  "</button>" +
includes/class-wpvivid-mysqldump-method.php CHANGED
@@ -926,15 +926,31 @@ class TypeAdapterMysql extends TypeAdapterFactory
926
  return $colInfo;
927
  }
928
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
  public function backup_parameters()
930
  {
 
931
  $this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
932
  $args = func_get_args();
933
  $dumpSettings = $args[0];
934
  $ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL .
935
  "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL .
936
  "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL .
937
- "/*!40101 SET NAMES " . $dumpSettings['default-character-set'] . " */;" . PHP_EOL;
938
 
939
  if (false === $dumpSettings['skip-tz-utc']) {
940
  $ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL .
@@ -1506,15 +1522,31 @@ class TypeAdapterWpdb extends TypeAdapterFactory
1506
  return $colInfo;
1507
  }
1508
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1509
  public function backup_parameters()
1510
  {
 
1511
  $this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
1512
  $args = func_get_args();
1513
  $dumpSettings = $args[0];
1514
  $ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL .
1515
  "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL .
1516
  "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL .
1517
- "/*!40101 SET NAMES " . $dumpSettings['default-character-set'] . " */;" . PHP_EOL;
1518
 
1519
  if (false === $dumpSettings['skip-tz-utc']) {
1520
  $ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL .
926
  return $colInfo;
927
  }
928
 
929
+ public function get_connection_charset($wpdb = null) {
930
+ if (null === $wpdb) {
931
+ global $wpdb;
932
+ }
933
+
934
+ $charset = (defined('DB_CHARSET') && DB_CHARSET) ? DB_CHARSET : 'utf8mb4';
935
+
936
+ if (method_exists($wpdb, 'determine_charset')) {
937
+ $charset_collate = $wpdb->determine_charset($charset, '');
938
+ if (!empty($charset_collate['charset'])) $charset = $charset_collate['charset'];
939
+ }
940
+
941
+ return $charset;
942
+ }
943
+
944
  public function backup_parameters()
945
  {
946
+ global $wpdb;
947
  $this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
948
  $args = func_get_args();
949
  $dumpSettings = $args[0];
950
  $ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL .
951
  "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL .
952
  "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL .
953
+ "/*!40101 SET NAMES " . $this->get_connection_charset($wpdb) . " */;" . PHP_EOL;
954
 
955
  if (false === $dumpSettings['skip-tz-utc']) {
956
  $ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL .
1522
  return $colInfo;
1523
  }
1524
 
1525
+ public function get_connection_charset($wpdb = null) {
1526
+ if (null === $wpdb) {
1527
+ global $wpdb;
1528
+ }
1529
+
1530
+ $charset = (defined('DB_CHARSET') && DB_CHARSET) ? DB_CHARSET : 'utf8mb4';
1531
+
1532
+ if (method_exists($wpdb, 'determine_charset')) {
1533
+ $charset_collate = $wpdb->determine_charset($charset, '');
1534
+ if (!empty($charset_collate['charset'])) $charset = $charset_collate['charset'];
1535
+ }
1536
+
1537
+ return $charset;
1538
+ }
1539
+
1540
  public function backup_parameters()
1541
  {
1542
+ global $wpdb;
1543
  $this->check_parameters(func_num_args(), $expected_num_args = 1, __METHOD__);
1544
  $args = func_get_args();
1545
  $dumpSettings = $args[0];
1546
  $ret = "/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" . PHP_EOL .
1547
  "/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;" . PHP_EOL .
1548
  "/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;" . PHP_EOL .
1549
+ "/*!40101 SET NAMES " . $this->get_connection_charset($wpdb) . " */;" . PHP_EOL;
1550
 
1551
  if (false === $dumpSettings['skip-tz-utc']) {
1552
  $ret .= "/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;" . PHP_EOL .
includes/class-wpvivid-restore-database.php CHANGED
@@ -820,7 +820,7 @@ class WPvivid_RestoreDB
820
  $query=str_replace($table_name,$new_table_name,$query);
821
  }
822
  }
823
-
824
  $this->execute_sql($query);
825
  }
826
 
820
  $query=str_replace($table_name,$new_table_name,$query);
821
  }
822
  }
823
+ //$query=str_replace('INSERT INTO', 'INSERT IGNORE INTO', $query);
824
  $this->execute_sql($query);
825
  }
826
 
includes/class-wpvivid.php CHANGED
@@ -2361,12 +2361,8 @@ class WPvivid {
2361
  // send the current file part to the browser
2362
  print fread($file, round($download_rate * 1024));
2363
  // flush the content to the browser
 
2364
  flush();
2365
-
2366
- if (ob_get_level())
2367
- {
2368
- ob_end_clean();
2369
- }
2370
  // sleep one second
2371
  sleep(1);
2372
  }
@@ -4659,6 +4655,7 @@ class WPvivid {
4659
  //WPvivid_Schedule::reset_schedule();
4660
  do_action('wpvivid_reset_schedule');
4661
  $ret['result'] = 'success';
 
4662
  echo json_encode($ret);
4663
  } else {
4664
  $ret['result'] = 'failed';
2361
  // send the current file part to the browser
2362
  print fread($file, round($download_rate * 1024));
2363
  // flush the content to the browser
2364
+ ob_flush();
2365
  flush();
 
 
 
 
 
2366
  // sleep one second
2367
  sleep(1);
2368
  }
4655
  //WPvivid_Schedule::reset_schedule();
4656
  do_action('wpvivid_reset_schedule');
4657
  $ret['result'] = 'success';
4658
+ $ret['slug'] = apply_filters('wpvivid_white_label_slug', 'WPvivid');
4659
  echo json_encode($ret);
4660
  } else {
4661
  $ret['result'] = 'failed';
includes/customclass/class-wpvivid-google-drive.php CHANGED
@@ -129,6 +129,13 @@ class Wpvivid_Google_drive extends WPvivid_Remote
129
 
130
  return;
131
  }
 
 
 
 
 
 
 
132
 
133
  global $wpvivid_plugin;
134
 
@@ -613,12 +620,16 @@ class Wpvivid_Google_drive extends WPvivid_Remote
613
  $wpvivid_plugin->wpvivid_log->WriteLog('Refresh the token.','notice');
614
  if ($client->getRefreshToken())
615
  {
 
616
  $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
617
  $token=$client->getAccessToken();
618
  $remote_options=WPvivid_Setting::get_remote_option($this->options['id']);
619
  $this->options['token']=json_decode(json_encode($token),1);
620
  if($remote_options!==false)
621
  {
 
 
 
622
  $remote_options['token']=$this->options['token'];
623
  WPvivid_Setting::update_remote_option($this->options['id'],$remote_options);
624
  }
@@ -725,9 +736,13 @@ class Wpvivid_Google_drive extends WPvivid_Remote
725
  // Refresh the token if possible, else fetch a new one.
726
  if ($client->getRefreshToken())
727
  {
 
728
  $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
729
  $token=$client->getAccessToken();
730
  $this->options['token']=json_decode(json_encode($token),1);
 
 
 
731
  WPvivid_Setting::update_remote_option($this->options['id'],$this->options);
732
  return array('result' => WPVIVID_SUCCESS,'data' => $client);
733
  }
129
 
130
  return;
131
  }
132
+ if(isset($_POST) && !empty($_POST) && !isset($_POST['refresh_token']))
133
+ {
134
+ $err = 'No refresh token was received from Google, which means that you entered client secret incorrectly, or that you did not re-authenticated yet after you corrected it. Please authenticate again.';
135
+ header('Location: '.admin_url().'admin.php?page='.WPVIVID_PLUGIN_SLUG.'&action=wpvivid_google_drive&result=error&resp_msg='.$err);
136
+
137
+ return;
138
+ }
139
 
140
  global $wpvivid_plugin;
141
 
620
  $wpvivid_plugin->wpvivid_log->WriteLog('Refresh the token.','notice');
621
  if ($client->getRefreshToken())
622
  {
623
+ $tmp_refresh_token = $client->getRefreshToken();
624
  $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
625
  $token=$client->getAccessToken();
626
  $remote_options=WPvivid_Setting::get_remote_option($this->options['id']);
627
  $this->options['token']=json_decode(json_encode($token),1);
628
  if($remote_options!==false)
629
  {
630
+ if(!isset($this->options['token']['refresh_token'])){
631
+ $this->options['token']['refresh_token'] = $tmp_refresh_token;
632
+ }
633
  $remote_options['token']=$this->options['token'];
634
  WPvivid_Setting::update_remote_option($this->options['id'],$remote_options);
635
  }
736
  // Refresh the token if possible, else fetch a new one.
737
  if ($client->getRefreshToken())
738
  {
739
+ $tmp_refresh_token = $client->getRefreshToken();
740
  $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
741
  $token=$client->getAccessToken();
742
  $this->options['token']=json_decode(json_encode($token),1);
743
+ if(!isset($this->options['token']['refresh_token'])){
744
+ $this->options['token']['refresh_token'] = $tmp_refresh_token;
745
+ }
746
  WPvivid_Setting::update_remote_option($this->options['id'],$this->options);
747
  return array('result' => WPVIVID_SUCCESS,'data' => $client);
748
  }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
- Tested up to: 5.4.2
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.43
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -179,6 +179,9 @@ Thank you for translating WPvivid Backup Plugin to your languages!
179
  * Valentin Lyong (Bulgarian)
180
 
181
  == Changelog ==
 
 
 
182
  = 0.9.43 =
183
  - Optimized migration process.
184
  - Fixed some bugs in the plugin code.
2
  Contributors: wpvivid
3
  Tags: move, clone, migrate, copy, backup, restore, auto backup, cloud backup
4
  Requires at least: 4.5
5
+ Tested up to: 5.5
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.44
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
179
  * Valentin Lyong (Bulgarian)
180
 
181
  == Changelog ==
182
+ = 0.9.44 =
183
+ - Successfully tested with WordPress 5.5.
184
+ - Fixed: Refreshing Google Drive token failed in some cases.
185
  = 0.9.43 =
186
  - Optimized migration process.
187
  - Fixed some bugs in the plugin code.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
- * Version: 0.9.43
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
@@ -21,7 +21,7 @@ if ( ! defined( 'WPINC' ) ) {
21
  die;
22
  }
23
 
24
- define( 'WPVIVID_PLUGIN_VERSION', '0.9.43' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: WPvivid Backup Plugin
9
  * Description: Clone or copy WP sites then move or migrate them to new host (new domain), schedule backups, transfer backups to leading remote storage. All in one.
10
+ * Version: 0.9.44
11
  * Author: WPvivid Team
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.44' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');