Migration, Backup, Staging – WPvivid - Version 0.9.13

Version Description

  • Fixed: Sometimes could not correctly determine database privileges when backing up.
Download this release

Release Info

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

Code changes from version 0.9.12 to 0.9.13

admin/js/wpvivid-admin.js CHANGED
@@ -269,6 +269,7 @@ function wpvivid_check_runningtask(){
269
  m_need_update = true;
270
  }
271
  else if (value.status.str === 'wait_resume') {
 
272
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
273
  jQuery('#wpvivid_postbox_backup_percent').show();
274
  jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
269
  m_need_update = true;
270
  }
271
  else if (value.status.str === 'wait_resume') {
272
+ running_backup_taskid = index;
273
  jQuery('#wpvivid_quickbackup_btn').css({'pointer-events': 'none', 'opacity': '0.4'});
274
  jQuery('#wpvivid_postbox_backup_percent').show();
275
  jQuery('#wpvivid_postbox_backup_percent').html(value.progress_html);
includes/class-wpvivid-backup-database.php CHANGED
@@ -3,7 +3,6 @@
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
6
- define('NECESSARY','1');
7
  define('OPTION','0');
8
  class WPvivid_Backup_Database
9
  {
@@ -22,9 +21,6 @@ class WPvivid_Backup_Database
22
  private $task_id;
23
  public $must_privilege = array(
24
  'backup' => array(
25
- 'SELECT' => NECESSARY,
26
- 'INSERT' => NECESSARY,
27
- 'UPDATE' => NECESSARY,
28
  'SHOW VIEW' => OPTION,
29
  'LOCK TABLES' => OPTION,
30
  'EVENT' => OPTION,
@@ -32,11 +28,6 @@ class WPvivid_Backup_Database
32
  'CREATE ROUTINE' => OPTION,
33
  ),
34
  'restore' => array(
35
- 'SELECT' => NECESSARY,
36
- 'INSERT' => NECESSARY,
37
- 'UPDATE' => NECESSARY,
38
- 'DROP' => NECESSARY,
39
- 'CREATE' => NECESSARY,
40
  'SHOW VIEW' => OPTION,
41
  'EVENT' => OPTION,
42
  'TRIGGER' => OPTION,
@@ -171,10 +162,11 @@ class WPvivid_Backup_Database
171
 
172
  $files = array();
173
  $files[] = $backup_file;
174
- return array('result'=>'succeed','files'=>$files);
175
  }
176
 
177
- public function check_privilege($type,$pdo){
 
178
  global $wpvivid_pulgin;
179
  $temp_privileges = array();
180
  foreach ($this -> must_privilege[$type] as $key => $value){
@@ -196,7 +188,8 @@ class WPvivid_Backup_Database
196
  if($result && $result->rowCount()>0)
197
  {
198
  $datas = $result -> fetchAll();
199
- foreach ($datas as $data){
 
200
  $sql = $data[0];
201
  if(stristr($sql,'USAGE'))
202
  continue;
@@ -204,49 +197,52 @@ class WPvivid_Backup_Database
204
  $pattern = "#^GRANT (.*?) TO '".DB_USER."'@'".$db_host."'#";
205
  preg_match_all($pattern,$sql,$result);
206
  $results = explode(' ON ',$result[1][0]);
207
- $tables = explode('.',$results[1]);
208
 
209
- if(trim($tables[0],'`') == '*' || trim($tables[0],'`') == DB_NAME){
 
 
210
  $privileges = trim($results[0]);
211
  $privileges = strtoupper($privileges);
212
- if($privileges == 'ALL PRIVILEGES'){
213
- foreach ($temp_privileges as $key => $value){
 
 
214
  $temp_privileges[$key] = 1;
215
  }
216
- }else{
217
  $privileges = explode(',',$privileges);
218
- foreach ($privileges as $privilege){
 
219
  $privilege = trim($privilege);
220
- if(array_key_exists($privilege,$temp_privileges)){
 
221
  $temp_privileges[$privilege] = 1;
222
  }
223
  }
224
  }
225
  }
226
  }
 
227
  }else{
228
- foreach ($temp_privileges as $key => $value){
 
229
  $temp_privileges[$key] = 1;
230
  }
231
 
232
  $wpvivid_pulgin->wpvivid_log->WriteLog('When performing database check, an anomaly is encountered.','notice');
233
  }
234
  $options = array();
235
- $necessary = array();
236
- foreach ($temp_privileges as $key => $value){
237
  if($value == 0){
238
- if($this -> must_privilege[$type][$key] === NECESSARY){
239
- $necessary[] = $key;
240
- }
241
- if($this -> must_privilege[$type][$key] === OPTION){
242
  $options[] = $key;
243
  }
244
  }
245
  }
246
- if(!empty($necessary)){
247
- return array('result' => WPVIVID_FAILED,'error' => 'Please grant the following database privileges: '.implode(',',$necessary));
248
- }
249
- if(!empty($options)){
250
  global $wpvivid_pulgin;
251
  $wpvivid_pulgin->wpvivid_log->WriteLog('The lack of optional database privileges including '.implode(',',$options),'notice');
252
  }
3
  if (!defined('WPVIVID_PLUGIN_DIR')){
4
  die;
5
  }
 
6
  define('OPTION','0');
7
  class WPvivid_Backup_Database
8
  {
21
  private $task_id;
22
  public $must_privilege = array(
23
  'backup' => array(
 
 
 
24
  'SHOW VIEW' => OPTION,
25
  'LOCK TABLES' => OPTION,
26
  'EVENT' => OPTION,
28
  'CREATE ROUTINE' => OPTION,
29
  ),
30
  'restore' => array(
 
 
 
 
 
31
  'SHOW VIEW' => OPTION,
32
  'EVENT' => OPTION,
33
  'TRIGGER' => OPTION,
162
 
163
  $files = array();
164
  $files[] = $backup_file;
165
+ return array('result'=>WPVIVID_SUCCESS,'files'=>$files);
166
  }
167
 
168
+ public function check_privilege($type,$pdo)
169
+ {
170
  global $wpvivid_pulgin;
171
  $temp_privileges = array();
172
  foreach ($this -> must_privilege[$type] as $key => $value){
188
  if($result && $result->rowCount()>0)
189
  {
190
  $datas = $result -> fetchAll();
191
+ foreach ($datas as $data)
192
+ {
193
  $sql = $data[0];
194
  if(stristr($sql,'USAGE'))
195
  continue;
197
  $pattern = "#^GRANT (.*?) TO '".DB_USER."'@'".$db_host."'#";
198
  preg_match_all($pattern,$sql,$result);
199
  $results = explode(' ON ',$result[1][0]);
 
200
 
201
+ $tables = explode('.',$results[1]);
202
+ if(trim($tables[0],'`') == '*' || trim($tables[0],'`') == DB_NAME)
203
+ {
204
  $privileges = trim($results[0]);
205
  $privileges = strtoupper($privileges);
206
+ if($privileges == 'ALL PRIVILEGES')
207
+ {
208
+ foreach ($temp_privileges as $key => $value)
209
+ {
210
  $temp_privileges[$key] = 1;
211
  }
212
+ }else {
213
  $privileges = explode(',',$privileges);
214
+ foreach ($privileges as $privilege)
215
+ {
216
  $privilege = trim($privilege);
217
+ if(array_key_exists($privilege,$temp_privileges))
218
+ {
219
  $temp_privileges[$privilege] = 1;
220
  }
221
  }
222
  }
223
  }
224
  }
225
+
226
  }else{
227
+ foreach ($temp_privileges as $key => $value)
228
+ {
229
  $temp_privileges[$key] = 1;
230
  }
231
 
232
  $wpvivid_pulgin->wpvivid_log->WriteLog('When performing database check, an anomaly is encountered.','notice');
233
  }
234
  $options = array();
235
+ foreach ($temp_privileges as $key => $value)
236
+ {
237
  if($value == 0){
238
+ if($this -> must_privilege[$type][$key] === OPTION)
239
+ {
 
 
240
  $options[] = $key;
241
  }
242
  }
243
  }
244
+ if(!empty($options))
245
+ {
 
 
246
  global $wpvivid_pulgin;
247
  $wpvivid_pulgin->wpvivid_log->WriteLog('The lack of optional database privileges including '.implode(',',$options),'notice');
248
  }
includes/class-wpvivid-backup.php CHANGED
@@ -130,7 +130,7 @@ class WPvivid_Backup{
130
  $result = $this->backup_loop_ex($data);
131
  }
132
 
133
- if($result['result'] == 'succeed')
134
  {
135
  if($this->i_progress<100)
136
  $this->i_progress+=$this->i_step;
@@ -151,7 +151,7 @@ class WPvivid_Backup{
151
  {
152
  $zip_result = array
153
  (
154
- 'result' => 'succeed',
155
  'ismerge' => $this->options['ismerge'] ,
156
  'data' => array
157
  (
@@ -167,7 +167,7 @@ class WPvivid_Backup{
167
  $wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to compress backup_merge.','notice');
168
  $res =$this->Merge_backup($type);
169
 
170
- if($res['result'] == 'succeed')
171
  {
172
  $wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' succeeded.','notice');
173
  $zip_result['data']['meta']=array('type_name' => WPVIVID_BACKUP_TYPE_MERGE , 'files' => $res['files']);
@@ -176,7 +176,7 @@ class WPvivid_Backup{
176
  {
177
  $wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' failed, error: '.$error,'notice');
178
  $zip_result =array(
179
- 'result' => 'failed',
180
  'error' => $error,
181
  );
182
  }
@@ -184,12 +184,12 @@ class WPvivid_Backup{
184
  }else {
185
  $zip_result= array
186
  (
187
- 'result' => 'failed',
188
  'error' => $error,
189
  );
190
  }
191
 
192
- if($zip_result['result']=='succeed')
193
  {
194
  WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'backup',100,1,$zip_result);
195
  }
@@ -232,7 +232,7 @@ class WPvivid_Backup{
232
  $this->log->WriteLog('Start exporting database.','notice');
233
  $result = $backup_database -> backup_database($data,$this->task_id);
234
  $this->log->WriteLog('Exporting database finished.','notice');
235
- if($result['result']=='succeed')
236
  {
237
  $files=$result['files'];
238
  //$files[]=$this->create_backup_json('db');
@@ -256,11 +256,11 @@ class WPvivid_Backup{
256
  }
257
  $res = array();
258
 
259
- if(!empty($result['result']) && $result['result'] == 'failed')
260
  {
261
  $res = $result;
262
  }else{
263
- $res['result'] = 'succeed';
264
  $res['files'] = $result['meta'];
265
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',$data['type'],1,'Backing up '.$data['type'].' finished.',$res);
266
  }
@@ -288,14 +288,14 @@ class WPvivid_Backup{
288
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,0,'Start compressing backup packages for a complete backup.');
289
  $result = $backup_site -> backup_files($data,$file_list,$this->task_id);
290
  $res = array();
291
- if(!is_array($result))
292
  {
293
  $this->log->WriteLog('File compression failed, error: '.$result['error'],'notice');
294
- $res['result'] = 'failed';
295
  $res['error'] = $result['error'];
296
  }else{
297
  $this->log->WriteLog('File compression finished.','notice');
298
- $res['result'] = 'succeed';
299
  $res['files'] = $result['meta'];
300
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,1,'File compression finished.',$res);
301
  }
130
  $result = $this->backup_loop_ex($data);
131
  }
132
 
133
+ if($result['result'] == WPVIVID_SUCCESS)
134
  {
135
  if($this->i_progress<100)
136
  $this->i_progress+=$this->i_step;
151
  {
152
  $zip_result = array
153
  (
154
+ 'result' => WPVIVID_SUCCESS,
155
  'ismerge' => $this->options['ismerge'] ,
156
  'data' => array
157
  (
167
  $wpvivid_pulgin->wpvivid_log->WriteLog('Prepare to compress backup_merge.','notice');
168
  $res =$this->Merge_backup($type);
169
 
170
+ if($res['result'] == WPVIVID_SUCCESS)
171
  {
172
  $wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' succeeded.','notice');
173
  $zip_result['data']['meta']=array('type_name' => WPVIVID_BACKUP_TYPE_MERGE , 'files' => $res['files']);
176
  {
177
  $wpvivid_pulgin->wpvivid_log->WriteLog('Compressing '.WPVIVID_BACKUP_TYPE_MERGE.' failed, error: '.$error,'notice');
178
  $zip_result =array(
179
+ 'result' => WPVIVID_FAILED,
180
  'error' => $error,
181
  );
182
  }
184
  }else {
185
  $zip_result= array
186
  (
187
+ 'result' => WPVIVID_FAILED,
188
  'error' => $error,
189
  );
190
  }
191
 
192
+ if($zip_result['result']==WPVIVID_SUCCESS)
193
  {
194
  WPvivid_taskmanager::update_backup_main_task_progress($this->task_id,'backup',100,1,$zip_result);
195
  }
232
  $this->log->WriteLog('Start exporting database.','notice');
233
  $result = $backup_database -> backup_database($data,$this->task_id);
234
  $this->log->WriteLog('Exporting database finished.','notice');
235
+ if($result['result']==WPVIVID_SUCCESS)
236
  {
237
  $files=$result['files'];
238
  //$files[]=$this->create_backup_json('db');
256
  }
257
  $res = array();
258
 
259
+ if($result['result'] == WPVIVID_FAILED)
260
  {
261
  $res = $result;
262
  }else{
263
+ $res['result'] = WPVIVID_SUCCESS;
264
  $res['files'] = $result['meta'];
265
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',$data['type'],1,'Backing up '.$data['type'].' finished.',$res);
266
  }
288
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,0,'Start compressing backup packages for a complete backup.');
289
  $result = $backup_site -> backup_files($data,$file_list,$this->task_id);
290
  $res = array();
291
+ if($result['result'] == WPVIVID_FAILED)
292
  {
293
  $this->log->WriteLog('File compression failed, error: '.$result['error'],'notice');
294
+ $res['result'] = WPVIVID_FAILED;
295
  $res['error'] = $result['error'];
296
  }else{
297
  $this->log->WriteLog('File compression finished.','notice');
298
+ $res['result'] = WPVIVID_SUCCESS;
299
  $res['files'] = $result['meta'];
300
  WPvivid_taskmanager::update_backup_sub_task_progress($this->task_id,'backup',WPVIVID_BACKUP_TYPE_MERGE,1,'File compression finished.',$res);
301
  }
includes/class-wpvivid-downloader.php CHANGED
@@ -368,7 +368,7 @@ class WPvivid_downloader
368
  foreach ($remotes as $remote)
369
  {
370
  $download_ret=self::download($remote,$file,$download_path,$task_id);
371
- if($download_ret['result']=='succeed')
372
  {
373
  $need_download=false;
374
  break;
368
  foreach ($remotes as $remote)
369
  {
370
  $download_ret=self::download($remote,$file,$download_path,$task_id);
371
+ if($download_ret['result']==WPVIVID_SUCCESS)
372
  {
373
  $need_download=false;
374
  break;
includes/class-wpvivid-restore-database.php CHANGED
@@ -29,7 +29,7 @@ class WPvivid_RestoreDB
29
  }
30
  $this->restore_data->write_log('Unzip sql file.','notice');
31
  $result = $zip -> zipextract($expath,$databases);
32
- if($result['result'] !== 'succeed'){
33
  return $result;
34
  }
35
  $file_path = $expath.DIRECTORY_SEPARATOR.$basename.'.sql';
@@ -76,7 +76,7 @@ class WPvivid_RestoreDB
76
  $this->restore_data->write_log('The lack of optional database privileges including '.implode(',',$options),'notice');
77
 
78
  $result = $backup_database ->backup_database(array('path'=>$temp_sql_file,'log'=>$this->restore_data->get_log_handle()));
79
- if($result['result'] != 'succeed')
80
  {
81
  return array('result' => 'failed','error' => $result['error']);
82
  }else{
@@ -87,7 +87,7 @@ class WPvivid_RestoreDB
87
  $data = array();
88
  $data['data']['file'] = $file_path;
89
  $str = $this ->restore_db($data);
90
- if($str['result'] == 'succeed')
91
  {
92
  WPvivid_Setting::import_json_to_setting($temp_sql);
93
  return $str;
@@ -205,6 +205,6 @@ class WPvivid_RestoreDB
205
  $this->restore_data->write_log('Restore database successfully.','notice');
206
  }
207
 
208
- return array('result'=>'succeed','meta'=>$error_info,'table'=>array('succeed'=>$success_num,'failed'=>$error_num));
209
  }
210
  }
29
  }
30
  $this->restore_data->write_log('Unzip sql file.','notice');
31
  $result = $zip -> zipextract($expath,$databases);
32
+ if($result['result'] !== WPVIVID_SUCCESS){
33
  return $result;
34
  }
35
  $file_path = $expath.DIRECTORY_SEPARATOR.$basename.'.sql';
76
  $this->restore_data->write_log('The lack of optional database privileges including '.implode(',',$options),'notice');
77
 
78
  $result = $backup_database ->backup_database(array('path'=>$temp_sql_file,'log'=>$this->restore_data->get_log_handle()));
79
+ if($result['result'] != WPVIVID_SUCCESS)
80
  {
81
  return array('result' => 'failed','error' => $result['error']);
82
  }else{
87
  $data = array();
88
  $data['data']['file'] = $file_path;
89
  $str = $this ->restore_db($data);
90
+ if($str['result'] == WPVIVID_SUCCESS)
91
  {
92
  WPvivid_Setting::import_json_to_setting($temp_sql);
93
  return $str;
205
  $this->restore_data->write_log('Restore database successfully.','notice');
206
  }
207
 
208
+ return array('result'=>WPVIVID_SUCCESS,'meta'=>$error_info,'table'=>array('succeed'=>$success_num,'failed'=>$error_num));
209
  }
210
  }
includes/class-wpvivid-restore-site.php CHANGED
@@ -22,7 +22,7 @@ class WPvivid_RestoreSite
22
  $except_path = $backup -> get_default_exclude_regex($type_name);
23
  $src_path = $backup->get_default_directory($type_name);
24
  $result = $this -> pre_restore($src_path,$temp_path,$except_path);
25
- if($result['result'] != 'succeed')
26
  return $result;
27
 
28
  $data= array(
@@ -43,7 +43,7 @@ class WPvivid_RestoreSite
43
  return $this -> _pre_restore_loop($path,$temp_path,$except_path,$path);
44
  }
45
  private function _pre_restore_loop($path,$temp_path,$except_path,$replace_path){
46
- $result = array('result'=>'succeed');
47
 
48
  if(empty($path)) {
49
  return array('result'=>'failed','error'=>'Failed to retrieve website\'s folder path. Please reinstall the plugin and try again.');
@@ -60,7 +60,7 @@ class WPvivid_RestoreSite
60
  if(WPvivid_tools::regex_match($except_path['directory'],$path.DIRECTORY_SEPARATOR.$filename,0)){
61
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
62
  $result = $this->_pre_restore_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$except_path,$replace_path);
63
- if($result['result'] != 'succeed')
64
  break;
65
  }
66
  }else{
@@ -95,7 +95,7 @@ class WPvivid_RestoreSite
95
  return $this -> _restore_copy_loop($src_path,$dst_path,$replace_path);
96
  }
97
  private function _restore_copy_loop($path,$temp_path,$replace_path){
98
- $result = array('result'=>'succeed');
99
  if(empty($path)) {
100
  return array('result'=>'failed','error'=>'The old folder not found. It may be deleted, renamed, or moved. Please verify the folder exists.');
101
  }
@@ -107,7 +107,7 @@ class WPvivid_RestoreSite
107
  if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
108
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
109
  $result = $this->_restore_copy_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$replace_path);
110
- if($result['result'] != 'succeed')
111
  break;
112
  }else{
113
  if(file_exists($path.DIRECTORY_SEPARATOR.$filename)){
22
  $except_path = $backup -> get_default_exclude_regex($type_name);
23
  $src_path = $backup->get_default_directory($type_name);
24
  $result = $this -> pre_restore($src_path,$temp_path,$except_path);
25
+ if($result['result'] != WPVIVID_SUCCESS)
26
  return $result;
27
 
28
  $data= array(
43
  return $this -> _pre_restore_loop($path,$temp_path,$except_path,$path);
44
  }
45
  private function _pre_restore_loop($path,$temp_path,$except_path,$replace_path){
46
+ $result = array('result'=>WPVIVID_SUCCESS);
47
 
48
  if(empty($path)) {
49
  return array('result'=>'failed','error'=>'Failed to retrieve website\'s folder path. Please reinstall the plugin and try again.');
60
  if(WPvivid_tools::regex_match($except_path['directory'],$path.DIRECTORY_SEPARATOR.$filename,0)){
61
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
62
  $result = $this->_pre_restore_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$except_path,$replace_path);
63
+ if($result['result'] != WPVIVID_SUCCESS)
64
  break;
65
  }
66
  }else{
95
  return $this -> _restore_copy_loop($src_path,$dst_path,$replace_path);
96
  }
97
  private function _restore_copy_loop($path,$temp_path,$replace_path){
98
+ $result = array('result'=>WPVIVID_SUCCESS);
99
  if(empty($path)) {
100
  return array('result'=>'failed','error'=>'The old folder not found. It may be deleted, renamed, or moved. Please verify the folder exists.');
101
  }
107
  if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
108
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
109
  $result = $this->_restore_copy_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$replace_path);
110
+ if($result['result'] != WPVIVID_SUCCESS)
111
  break;
112
  }else{
113
  if(file_exists($path.DIRECTORY_SEPARATOR.$filename)){
includes/class-wpvivid-restore.php CHANGED
@@ -24,7 +24,7 @@ class WPvivid_Restore{
24
 
25
  $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup['local']['path'];
26
 
27
- if($backup['backup']['result'] == 'succeed')
28
  {
29
  if($next_task===false)
30
  {
@@ -58,7 +58,7 @@ class WPvivid_Restore{
58
  $res = $zip -> get_include_zip($files,$allpackages);
59
  foreach ($res as $key => $value){
60
  $result = $zip -> zipextract_by_files($temp_expath,$value,$key);
61
- if($result['result'] !== 'succeed')
62
  return $result;
63
  }
64
  $temp_expath .= DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
@@ -75,7 +75,7 @@ class WPvivid_Restore{
75
 
76
  if(!empty($result['table']))
77
  $table = $result['table'];
78
- if($result['result'] != 'succeed')
79
  {
80
  $this->restore_data->write_log($result['error'],'error');
81
  $this->restore_data->update_error($result,$next_task['type_name'],$table);
@@ -88,7 +88,7 @@ class WPvivid_Restore{
88
  $this->restore_data->write_log($next_task['type_name'].' restore completed: '.$table['succeed'].' succeeded, '.$table['failed'].' failed.','notice');
89
  $this->restore_data->update_sub_task_completed($next_task['type_name'],$result,$table);
90
  $this->restore_data->update_status(WPVIVID_RESTORE_WAIT);
91
- return array('result'=> 'succeed');
92
  }
93
  }
94
  }else{
24
 
25
  $path = WP_CONTENT_DIR.DIRECTORY_SEPARATOR.$backup['local']['path'];
26
 
27
+ if($backup['backup']['result'] == WPVIVID_SUCCESS)
28
  {
29
  if($next_task===false)
30
  {
58
  $res = $zip -> get_include_zip($files,$allpackages);
59
  foreach ($res as $key => $value){
60
  $result = $zip -> zipextract_by_files($temp_expath,$value,$key);
61
+ if($result['result'] !== WPVIVID_SUCCESS)
62
  return $result;
63
  }
64
  $temp_expath .= DIRECTORY_SEPARATOR.WPvivid_Setting::get_backupdir();
75
 
76
  if(!empty($result['table']))
77
  $table = $result['table'];
78
+ if($result['result'] != WPVIVID_SUCCESS)
79
  {
80
  $this->restore_data->write_log($result['error'],'error');
81
  $this->restore_data->update_error($result,$next_task['type_name'],$table);
88
  $this->restore_data->write_log($next_task['type_name'].' restore completed: '.$table['succeed'].' succeeded, '.$table['failed'].' failed.','notice');
89
  $this->restore_data->update_sub_task_completed($next_task['type_name'],$result,$table);
90
  $this->restore_data->update_status(WPVIVID_RESTORE_WAIT);
91
+ return array('result'=> WPVIVID_SUCCESS);
92
  }
93
  }
94
  }else{
includes/class-wpvivid-rollback.php CHANGED
@@ -36,7 +36,7 @@ class WPvivid_RollBack
36
  $table=array();
37
  if(!empty($result['table']))
38
  $table = $result['table'];
39
- if($result['result'] != 'succeed')
40
  {
41
  $this->restore_data->write_rollback_log($result['error'],'error');
42
  $this->restore_data->update_rollback_error($result,$next_task['type_name'],$table);
@@ -67,7 +67,7 @@ class WPvivid_RollBack
67
  $this->restore_data->write_rollback_log('Start rollbacking database.','notice');
68
  $File = $data['data']['file'];
69
  if(!file_exists($File)){
70
- return array('result'=>'failed','error'=>'The .sql file not found. Please try again later.');
71
  }
72
 
73
  $res = explode(':',DB_HOST);
@@ -139,10 +139,10 @@ class WPvivid_RollBack
139
  if($tables){
140
  foreach ($tables as $table){
141
  if(!$pdo -> query('DROP TABLE '.$table))
142
- return array('result'=>'failed','error' =>$pdo ->errorInfo());
143
  }
144
  }else{
145
- return array('result'=>'failed','error'=>$pdo->errorInfo());
146
  }
147
 
148
  while(!feof($sqlhandle)) {
@@ -182,7 +182,7 @@ class WPvivid_RollBack
182
  }else{
183
  $this->restore_data->write_rollback_log('Database rollback succeeded.','Notice');
184
  }
185
- return array('result'=>'succeed','meta'=>$error_info,'table'=>array('succeed'=>$success_num,'failed'=>$error_num));
186
  }
187
 
188
  private function rollback_copy($data){
@@ -192,7 +192,7 @@ class WPvivid_RollBack
192
  return $this -> _rollback_copy_loop($src_path,$dst_path,$replace_path);
193
  }
194
  private function _rollback_copy_loop($path,$temp_path,$replace_path){
195
- $result = array('result'=>'succeed');
196
  if(empty($path)) {
197
  return array('result'=>'failed','error'=>'Failed to retrieve website\'s folder path. Please reinstall the plugin and try again.');
198
  }
@@ -204,7 +204,7 @@ class WPvivid_RollBack
204
  if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
205
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
206
  $result = $this->_rollback_copy_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$replace_path);
207
- if($result['result'] != 'succeed')
208
  break;
209
  }else{
210
  if(!copy($path.DIRECTORY_SEPARATOR.$filename,str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename))){
36
  $table=array();
37
  if(!empty($result['table']))
38
  $table = $result['table'];
39
+ if($result['result'] != WPVIVID_SUCCESS)
40
  {
41
  $this->restore_data->write_rollback_log($result['error'],'error');
42
  $this->restore_data->update_rollback_error($result,$next_task['type_name'],$table);
67
  $this->restore_data->write_rollback_log('Start rollbacking database.','notice');
68
  $File = $data['data']['file'];
69
  if(!file_exists($File)){
70
+ return array('result'=>WPVIVID_FAILED,'error'=>'The .sql file not found. Please try again later.');
71
  }
72
 
73
  $res = explode(':',DB_HOST);
139
  if($tables){
140
  foreach ($tables as $table){
141
  if(!$pdo -> query('DROP TABLE '.$table))
142
+ return array('result'=>WPVIVID_FAILED,'error' =>$pdo ->errorInfo());
143
  }
144
  }else{
145
+ return array('result'=>WPVIVID_FAILED,'error'=>$pdo->errorInfo());
146
  }
147
 
148
  while(!feof($sqlhandle)) {
182
  }else{
183
  $this->restore_data->write_rollback_log('Database rollback succeeded.','Notice');
184
  }
185
+ return array('result'=>WPVIVID_SUCCESS,'meta'=>$error_info,'table'=>array('succeed'=>$success_num,'failed'=>$error_num));
186
  }
187
 
188
  private function rollback_copy($data){
192
  return $this -> _rollback_copy_loop($src_path,$dst_path,$replace_path);
193
  }
194
  private function _rollback_copy_loop($path,$temp_path,$replace_path){
195
+ $result = array('result'=>WPVIVID_SUCCESS);
196
  if(empty($path)) {
197
  return array('result'=>'failed','error'=>'Failed to retrieve website\'s folder path. Please reinstall the plugin and try again.');
198
  }
204
  if(is_dir($path.DIRECTORY_SEPARATOR.$filename)){
205
  @mkdir(str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename));
206
  $result = $this->_rollback_copy_loop($path.DIRECTORY_SEPARATOR.$filename,$temp_path,$replace_path);
207
+ if($result['result'] != WPVIVID_SUCCESS)
208
  break;
209
  }else{
210
  if(!copy($path.DIRECTORY_SEPARATOR.$filename,str_replace($replace_path,$temp_path,$path.DIRECTORY_SEPARATOR.$filename))){
includes/class-wpvivid-tools.php CHANGED
@@ -30,7 +30,7 @@ class WPvivid_tools
30
  }
31
  }
32
  closedir($dir);
33
- return array('result'=>'succeed');
34
  }
35
 
36
  public static function clearcache($task_id){
30
  }
31
  }
32
  closedir($dir);
33
+ return array('result'=>WPVIVID_SUCCESS);
34
  }
35
 
36
  public static function clearcache($task_id){
includes/class-wpvivid-zipclass.php CHANGED
@@ -104,9 +104,9 @@ class WPvivid_ZipClass {
104
  }
105
  }
106
  if($flag){
107
- return array('result'=>'succeed','table'=>$table,'error' => $error);
108
  }else{
109
- return array('result'=>'failed','error'=>$error);
110
  }
111
  }
112
 
@@ -137,7 +137,7 @@ class WPvivid_ZipClass {
137
  }
138
 
139
  if($flag){
140
- return array('result'=>'succeed','table'=>$table,'error' => $error);
141
  }else{
142
  return array('result'=>'failed','error'=>$error);
143
  }
@@ -263,7 +263,7 @@ class WPvivid_ZipClass {
263
  $files_meta[] = $file_data;
264
  }
265
  $wpvivid_pulgin->wpvivid_log->WriteLog('Adding zip files completed.','notice');
266
- return array('result'=>'succeed','meta'=>$files_meta);
267
  }
268
  }
269
 
104
  }
105
  }
106
  if($flag){
107
+ return array('result'=>WPVIVID_SUCCESS,'table'=>$table,'error' => $error);
108
  }else{
109
+ return array('result'=>WPVIVID_FAILED,'error'=>$error);
110
  }
111
  }
112
 
137
  }
138
 
139
  if($flag){
140
+ return array('result'=>WPVIVID_SUCCESS,'table'=>$table,'error' => $error);
141
  }else{
142
  return array('result'=>'failed','error'=>$error);
143
  }
263
  $files_meta[] = $file_data;
264
  }
265
  $wpvivid_pulgin->wpvivid_log->WriteLog('Adding zip files completed.','notice');
266
+ return array('result'=>WPVIVID_SUCCESS,'meta'=>$files_meta);
267
  }
268
  }
269
 
includes/class-wpvivid.php CHANGED
@@ -988,7 +988,7 @@ class WPvivid {
988
 
989
  WPvivid_tools::clearcache($task_id);
990
 
991
- if($backup_ret['result'] != 'succeed')
992
  {
993
  $this->wpvivid_log->WriteLog('Backup ends with an error '. $backup_ret['error'], 'error');
994
  }
@@ -1157,11 +1157,9 @@ class WPvivid {
1157
  }
1158
  $backup_success_count++;
1159
  WPvivid_Setting::update_option('wpvivid_backup_success_count', $backup_success_count);
1160
- $this->wpvivid_log->WriteLog('->succeed->01.','notice');
1161
  $this->wpvivid_analysis_backup($task);
1162
  WPvivid_Schedule::clear_monitor_schedule($task['id']);
1163
  WPvivid_mail_report::send_report_mail($task);
1164
- $this->wpvivid_log->WriteLog('->succeed->02.','notice');
1165
  $this->wpvivid_log->CloseFile();
1166
  }
1167
 
988
 
989
  WPvivid_tools::clearcache($task_id);
990
 
991
+ if($backup_ret['result'] != WPVIVID_SUCCESS)
992
  {
993
  $this->wpvivid_log->WriteLog('Backup ends with an error '. $backup_ret['error'], 'error');
994
  }
1157
  }
1158
  $backup_success_count++;
1159
  WPvivid_Setting::update_option('wpvivid_backup_success_count', $backup_success_count);
 
1160
  $this->wpvivid_analysis_backup($task);
1161
  WPvivid_Schedule::clear_monitor_schedule($task['id']);
1162
  WPvivid_mail_report::send_report_mail($task);
 
1163
  $this->wpvivid_log->CloseFile();
1164
  }
1165
 
includes/customclass/class-wpvivid-remote-default.php CHANGED
@@ -7,21 +7,21 @@ require_once WPVIVID_PLUGIN_DIR .'/includes/customclass/class-wpvivid-remote.php
7
  class WPvivid_Remote_Defult extends WPvivid_Remote{
8
  public function test_connect()
9
  {
10
- return array('result' => 'failed','error'=> 'Type incorrect.');
11
  }
12
 
13
  public function upload($task_id, $files, $callback = '')
14
  {
15
- return array('result' => 'failed','error'=> 'Type incorrect.');
16
  }
17
 
18
  public function download( $file, $local_path, $callback = '')
19
  {
20
- return array('result' => 'failed','error'=> 'Type incorrect.');
21
  }
22
 
23
  public function cleanup($files)
24
  {
25
- return array('result' => 'failed','error'=> 'Type incorrect.');
26
  }
27
  }
7
  class WPvivid_Remote_Defult extends WPvivid_Remote{
8
  public function test_connect()
9
  {
10
+ return array('result' => WPVIVID_FAILED,'error'=> 'Type incorrect.');
11
  }
12
 
13
  public function upload($task_id, $files, $callback = '')
14
  {
15
+ return array('result' => WPVIVID_FAILED,'error'=> 'Type incorrect.');
16
  }
17
 
18
  public function download( $file, $local_path, $callback = '')
19
  {
20
+ return array('result' => WPVIVID_FAILED,'error'=> 'Type incorrect.');
21
  }
22
 
23
  public function cleanup($files)
24
  {
25
+ return array('result' => WPVIVID_FAILED,'error'=> 'Type incorrect.');
26
  }
27
  }
includes/customclass/class-wpvivid-s3compat.php CHANGED
@@ -205,7 +205,7 @@ class Wpvivid_S3Compat extends WPvivid_Remote{
205
  )
206
  );
207
  if(!isset($ret['Location'])){
208
- $result = array('result' => 'failed', 'error' => 'Merging multipart failed. File name: '.$this -> current_file_name);
209
  }
210
  }
211
  }
205
  )
206
  );
207
  if(!isset($ret['Location'])){
208
+ $result = array('result' => WPVIVID_FAILED, 'error' => 'Merging multipart failed. File name: '.$this -> current_file_name);
209
  }
210
  }
211
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: backup, cloud backup, automatic backup, restore, database backup, wordpres
4
  Requires at least: 4.5
5
  Tested up to: 5.1
6
  Requires PHP: 5.3
7
- Stable tag: 0.9.12
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
@@ -126,6 +126,8 @@ Please try to contact your web hosting provider for changing PHP memory limit, o
126
  Feel free to let us know how we can help using the [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore) for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
127
 
128
  == Changelog ==
 
 
129
  = 0.9.12 =
130
  - Added an 'Send Debug Information to Us' button in Website Info page.
131
  - Improved the compatibility with PHP v5.3 to v5.5.
4
  Requires at least: 4.5
5
  Tested up to: 5.1
6
  Requires PHP: 5.3
7
+ Stable tag: 0.9.13
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10
 
126
  Feel free to let us know how we can help using the [support forum](https://wordpress.org/support/plugin/wpvivid-backuprestore) for the plugin on WordPress.org or our [contact form](https://wpvivid.com/contact-us). You can also reach us with a direct message on [Twitter](https://twitter.com/WPvividcom).
127
 
128
  == Changelog ==
129
+ = 0.9.13 =
130
+ - Fixed: Sometimes could not correctly determine database privileges when backing up.
131
  = 0.9.12 =
132
  - Added an 'Send Debug Information to Us' button in Website Info page.
133
  - Improved the compatibility with PHP v5.3 to v5.5.
wpvivid-backuprestore.php CHANGED
@@ -7,7 +7,7 @@
7
  * @wordpress-plugin
8
  * Plugin Name: Backup WordPress Site by WPvivid
9
  * Description: Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
10
- * Version: 0.9.12
11
  * Author: wpvivid.com
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.12' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');
7
  * @wordpress-plugin
8
  * Plugin Name: Backup WordPress Site by WPvivid
9
  * Description: Automatically back up WordPress to Cloud Storage (Dropbox, Amazon S3, Microsoft OneDrive, Google Drive etc), one-click restore. All free.
10
+ * Version: 0.9.13
11
  * Author: wpvivid.com
12
  * Author URI: https://wpvivid.com
13
  * License: GPL-3.0+
21
  die;
22
  }
23
 
24
+ define( 'WPVIVID_PLUGIN_VERSION', '0.9.13' );
25
  //
26
  define('WPVIVID_RESTORE_INIT','init');
27
  define('WPVIVID_RESTORE_READY','ready');