All-in-One WP Migration - Version 1.2.1

Version Description

  • Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
  • Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox
  • Fixed an issue when PDO is avalable but mysql driver for PDO is not, credit to Jaydesain69
  • Delete a plugin specific option when uninstalling the plugin (clean after itself)
  • Support is done via Zendesk
  • Include WP Version and Plugin version in the feedback form
Download this release

Release Info

Developer yani.iliev
Plugin Icon 128x128 All-in-One WP Migration
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2.0 to 1.2.1

all-in-one-wp-migration.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Migration tool for all your blog data
6
  * Author: ServMask
7
  * Author URI: http://servmask.com/
8
- * Version: 1.2.0
9
  *
10
  * Copyright (C) 2013 ServMask LLC
11
  *
@@ -26,10 +26,10 @@
26
  @ini_set( 'max_input_time', '-1' );
27
 
28
  // include constants
29
- require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php' );
30
 
31
  // include loader
32
- require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'loader.php' );
33
 
34
  // ==========================================================================
35
  // = All app initialization is done in Ai1wm_Main_Controller __constructor. =
5
  * Description: Migration tool for all your blog data
6
  * Author: ServMask
7
  * Author URI: http://servmask.com/
8
+ * Version: 1.2.1
9
  *
10
  * Copyright (C) 2013 ServMask LLC
11
  *
26
  @ini_set( 'max_input_time', '-1' );
27
 
28
  // include constants
29
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php';
30
 
31
  // include loader
32
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'loader.php';
33
 
34
  // ==========================================================================
35
  // = All app initialization is done in Ai1wm_Main_Controller __constructor. =
constants.php CHANGED
@@ -16,6 +16,11 @@
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
 
 
 
 
 
19
  // ===============
20
  // = Plugin Name =
21
  // ===============
@@ -71,6 +76,11 @@ define( 'AI1WM_URL', plugins_url( '', __FILE__ ) );
71
  // ==============
72
  define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
73
 
 
 
 
 
 
74
  // ===========================
75
  // = WP_CONTENT_DIR Constant =
76
  // ===========================
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
19
+ // ==================
20
+ // = Plugin VERSION =
21
+ // ==================
22
+ define( 'AI1WM_VERSION', '1.2.1' );
23
+
24
  // ===============
25
  // = Plugin Name =
26
  // ===============
76
  // ==============
77
  define( 'AI1WM_FEEDBACK_URL', 'https://servmask.com/ai1wm/feedback/create' );
78
 
79
+ // ==============
80
+ // = ServMask Table Prefix =
81
+ // ==============
82
+ define( 'AI1WM_TABLE_PREFIX', 'SERVMASK_PREFIX_' );
83
+
84
  // ===========================
85
  // = WP_CONTENT_DIR Constant =
86
  // ===========================
lib/model/class-ai1wm-export.php CHANGED
@@ -34,7 +34,11 @@ class Ai1wm_Export
34
  DB_USER,
35
  DB_PASSWORD,
36
  DB_NAME,
37
- class_exists( 'PDO' )
 
 
 
 
38
  );
39
  }
40
 
@@ -46,6 +50,15 @@ class Ai1wm_Export
46
  * @return string Absolute file path
47
  */
48
  public function export( $output_file, array $options = array() ) {
 
 
 
 
 
 
 
 
 
49
  // Export last options
50
  update_option( self::EXPORT_LAST_OPTIONS, json_encode( $options ) );
51
 
@@ -153,6 +166,8 @@ class Ai1wm_Export
153
  ->setIncludeTables( $includeTables )
154
  ->setExcludeTables( $excludeTables )
155
  ->setNoTableData( $noTableData )
 
 
156
  ->setQueryClauses( $clauses );
157
 
158
  // Make dump
34
  DB_USER,
35
  DB_PASSWORD,
36
  DB_NAME,
37
+ (
38
+ class_exists(
39
+ 'PDO'
40
+ ) && in_array( 'mysql', PDO::getAvailableDrivers() )
41
+ )
42
  );
43
  }
44
 
50
  * @return string Absolute file path
51
  */
52
  public function export( $output_file, array $options = array() ) {
53
+ global $wp_version;
54
+ $options['plugin_version'] = AI1WM_VERSION;
55
+ $options['wp_version'] = $wp_version;
56
+ $options['php_version'] = phpversion();
57
+ $options['ZipArchive'] = class_exists( 'ZipArchive' ) ? 1 : 0;
58
+ $options['ZLIB_installed'] = function_exists( 'gzopen' ) ? 1 : 0;
59
+ $options['PDO_available'] = class_exists( 'PDO' ) ? 1 : 0;
60
+ $options['home_url'] = home_url();
61
+
62
  // Export last options
63
  update_option( self::EXPORT_LAST_OPTIONS, json_encode( $options ) );
64
 
166
  ->setIncludeTables( $includeTables )
167
  ->setExcludeTables( $excludeTables )
168
  ->setNoTableData( $noTableData )
169
+ ->setOldTablePrefix( $wpdb->prefix )
170
+ ->setNewTablePrefix( AI1WM_TABLE_PREFIX )
171
  ->setQueryClauses( $clauses );
172
 
173
  // Make dump
lib/model/class-ai1wm-import.php CHANGED
@@ -29,7 +29,11 @@ class Ai1wm_Import
29
  DB_USER,
30
  DB_PASSWORD,
31
  DB_NAME,
32
- class_exists( 'PDO' )
 
 
 
 
33
  );
34
  }
35
 
@@ -41,6 +45,7 @@ class Ai1wm_Import
41
  * @return array List of messages
42
  */
43
  public function import( $input_file, $options = array() ) {
 
44
  $errors = array();
45
 
46
  if ( empty( $input_file['error'] ) ) {
@@ -111,7 +116,9 @@ class Ai1wm_Import
111
  $this->connection->truncateDatabase();
112
 
113
  // Import database
114
- $this->connection->import( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME );
 
 
115
  }
116
 
117
  // Check if media files are present
@@ -169,12 +176,6 @@ class Ai1wm_Import
169
  $this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_PLUGINS_NAME, WP_PLUGIN_DIR );
170
  }
171
 
172
- if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME ) ) {
173
-
174
- // Install selected plugins
175
- $this->install_plugins( $extract_to . Ai1wm_Export::EXPORT_PACKAGE_NAME );
176
- }
177
-
178
  // Test website
179
  if ( ! $this->test_website( get_option( 'siteurl' ) ) ) {
180
  if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME ) ) {
@@ -182,7 +183,9 @@ class Ai1wm_Import
182
  $this->connection->truncateDatabase();
183
 
184
  // Import "OLD" database
185
- $this->connection->import( $database_file );
 
 
186
  }
187
 
188
  if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
@@ -287,42 +290,6 @@ class Ai1wm_Import
287
  }
288
  }
289
 
290
- /**
291
- * Install available plugins
292
- *
293
- * @param string $path Absolute path to package config file
294
- * @return void
295
- */
296
- public function install_plugins( $path ) {
297
- $file = file_get_contents( $path );
298
- $package = json_decode( $file, true );
299
-
300
- // For Plugins API
301
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
302
- include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
303
-
304
- // Install Plugins
305
- if ( isset( $package['Plugins'] ) && ( $install_plugins = $package['Plugins'] ) ) {
306
- foreach ( $install_plugins as $item ) {
307
- $plugin = $item['Slug'];
308
-
309
- $api = plugins_api( 'plugin_information', array( 'slug' => $plugin, 'fields' => array( 'sections' => false ) ) );
310
- if ( ! is_wp_error( $api ) ) {
311
- $status = install_plugin_install_status( $api );
312
- if ( $status['status'] == 'install' ) {
313
- $title = sprintf( __('Installing Plugin: %s'), $api->name . ' ' . $api->version );
314
- $nonce = 'install-plugin_' . $plugin;
315
- $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
316
- $type = 'web';
317
-
318
- $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
319
- @$upgrader->install( $api->download_link );
320
- }
321
- }
322
- }
323
- }
324
- }
325
-
326
  /**
327
  * Test webside whether everything is installed properly (Not implemented yet)
328
  *
29
  DB_USER,
30
  DB_PASSWORD,
31
  DB_NAME,
32
+ (
33
+ class_exists(
34
+ 'PDO'
35
+ ) && in_array( 'mysql', PDO::getAvailableDrivers() )
36
+ )
37
  );
38
  }
39
 
45
  * @return array List of messages
46
  */
47
  public function import( $input_file, $options = array() ) {
48
+ global $wpdb;
49
  $errors = array();
50
 
51
  if ( empty( $input_file['error'] ) ) {
116
  $this->connection->truncateDatabase();
117
 
118
  // Import database
119
+ $this->connection->setOldTablePrefix( AI1WM_TABLE_PREFIX )
120
+ ->setNewTablePrefix( $wpdb->prefix )
121
+ ->import( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME );
122
  }
123
 
124
  // Check if media files are present
176
  $this->copy_dir( $extract_to . Ai1wm_Export::EXPORT_PLUGINS_NAME, WP_PLUGIN_DIR );
177
  }
178
 
 
 
 
 
 
 
179
  // Test website
180
  if ( ! $this->test_website( get_option( 'siteurl' ) ) ) {
181
  if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_DATABASE_NAME ) ) {
183
  $this->connection->truncateDatabase();
184
 
185
  // Import "OLD" database
186
+ $this->connection->setOldTablePrefix( AI1WM_TABLE_PREFIX )
187
+ ->setNewTablePrefix( $wpdb->prefix )
188
+ ->import( $database_file );
189
  }
190
 
191
  if ( file_exists( $extract_to . Ai1wm_Export::EXPORT_MEDIA_NAME ) ) {
290
  }
291
  }
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  /**
294
  * Test webside whether everything is installed properly (Not implemented yet)
295
  *
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpInterface.php CHANGED
@@ -71,7 +71,7 @@ interface MysqlDumpInterface
71
  * Set output file name
72
  *
73
  * @param string $fileName Name of the output file
74
- * @return string
75
  */
76
  public function setFileName($fileName);
77
 
@@ -82,11 +82,41 @@ interface MysqlDumpInterface
82
  */
83
  public function getFileName();
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  /**
86
  * Set query clauses
87
  *
88
  * @param array $clauses List of SQL query clauses
89
- * @return array
90
  */
91
  public function setQueryClauses($clauses);
92
 
@@ -101,7 +131,7 @@ interface MysqlDumpInterface
101
  * Set include tables
102
  *
103
  * @param array $tables List of tables
104
- * @return array
105
  */
106
  public function setIncludeTables($tables);
107
 
@@ -116,7 +146,7 @@ interface MysqlDumpInterface
116
  * Set exclude tables
117
  *
118
  * @param array $tables List of tables
119
- * @return array
120
  */
121
  public function setExcludeTables($tables);
122
 
@@ -131,7 +161,7 @@ interface MysqlDumpInterface
131
  * Set no table data flag
132
  *
133
  * @param bool $flag Do not export table data
134
- * @return bool
135
  */
136
  public function setNoTableData($flag);
137
 
@@ -146,7 +176,7 @@ interface MysqlDumpInterface
146
  * Set add drop table flag
147
  *
148
  * @param bool $flag Add drop table SQL clause
149
- * @return bool
150
  */
151
  public function setAddDropTable($flag);
152
 
@@ -161,7 +191,7 @@ interface MysqlDumpInterface
161
  * Set extended insert flag
162
  *
163
  * @param bool $flag Add extended insert SQL clause
164
- * @return bool
165
  */
166
  public function setExtendedInsert($flag);
167
 
71
  * Set output file name
72
  *
73
  * @param string $fileName Name of the output file
74
+ * @return MysqlDumpInterface
75
  */
76
  public function setFileName($fileName);
77
 
82
  */
83
  public function getFileName();
84
 
85
+ /**
86
+ * Set old table prefix
87
+ *
88
+ * @param string $prefix Name of the table prefix
89
+ * @return MysqlDumpInterface
90
+ */
91
+ public function setOldTablePrefix($prefix);
92
+
93
+ /**
94
+ * Get old table prefix
95
+ *
96
+ * @return string
97
+ */
98
+ public function getOldTablePrefix();
99
+
100
+ /**
101
+ * Set new table prefix
102
+ *
103
+ * @param string $prefix Name of the table prefix
104
+ * @return MysqlDumpInterface
105
+ */
106
+ public function setNewTablePrefix($prefix);
107
+
108
+ /**
109
+ * Get new table prefix
110
+ *
111
+ * @return string
112
+ */
113
+ public function getNewTablePrefix();
114
+
115
  /**
116
  * Set query clauses
117
  *
118
  * @param array $clauses List of SQL query clauses
119
+ * @return MysqlDumpInterface
120
  */
121
  public function setQueryClauses($clauses);
122
 
131
  * Set include tables
132
  *
133
  * @param array $tables List of tables
134
+ * @return MysqlDumpInterface
135
  */
136
  public function setIncludeTables($tables);
137
 
146
  * Set exclude tables
147
  *
148
  * @param array $tables List of tables
149
+ * @return MysqlDumpInterface
150
  */
151
  public function setExcludeTables($tables);
152
 
161
  * Set no table data flag
162
  *
163
  * @param bool $flag Do not export table data
164
+ * @return MysqlDumpInterface
165
  */
166
  public function setNoTableData($flag);
167
 
176
  * Set add drop table flag
177
  *
178
  * @param bool $flag Add drop table SQL clause
179
+ * @return MysqlDumpInterface
180
  */
181
  public function setAddDropTable($flag);
182
 
191
  * Set extended insert flag
192
  *
193
  * @param bool $flag Add extended insert SQL clause
194
+ * @return MysqlDumpInterface
195
  */
196
  public function setExtendedInsert($flag);
197
 
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpPDO.php CHANGED
@@ -67,6 +67,10 @@ class MysqlDumpPDO implements MysqlDumpInterface
67
 
68
  protected $connection = null;
69
 
 
 
 
 
70
  protected $queryClauses = array();
71
 
72
  protected $includeTables = array();
@@ -141,7 +145,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
141
  * Set output file name
142
  *
143
  * @param string $fileName Name of the output file
144
- * @return string
145
  */
146
  public function setFileName($fileName)
147
  {
@@ -160,11 +164,57 @@ class MysqlDumpPDO implements MysqlDumpInterface
160
  return $this->fileName;
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /**
164
  * Set query clauses
165
  *
166
  * @param array $clauses List of SQL query clauses
167
- * @return array
168
  */
169
  public function setQueryClauses($clauses)
170
  {
@@ -187,7 +237,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
187
  * Set include tables
188
  *
189
  * @param array $tables List of tables
190
- * @return array
191
  */
192
  public function setIncludeTables($tables)
193
  {
@@ -210,7 +260,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
210
  * Set exclude tables
211
  *
212
  * @param array $tables List of tables
213
- * @return array
214
  */
215
  public function setExcludeTables($tables)
216
  {
@@ -233,7 +283,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
233
  * Set no table data flag
234
  *
235
  * @param bool $flag Do not export table data
236
- * @return bool
237
  */
238
  public function setNoTableData($flag)
239
  {
@@ -256,7 +306,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
256
  * Set add drop table flag
257
  *
258
  * @param bool $flag Add drop table SQL clause
259
- * @return bool
260
  */
261
  public function setAddDropTable($flag)
262
  {
@@ -279,7 +329,7 @@ class MysqlDumpPDO implements MysqlDumpInterface
279
  * Set extended insert flag
280
  *
281
  * @param bool $flag Add extended insert SQL clause
282
- * @return bool
283
  */
284
  public function setExtendedInsert($flag)
285
  {
@@ -327,6 +377,9 @@ class MysqlDumpPDO implements MysqlDumpInterface
327
 
328
  // Read database file line by line
329
  while (($line = fgets($fileHandler)) !== false) {
 
 
 
330
  $query .= $line;
331
  if (preg_match('/;\s*$/', $line)) {
332
  try {
@@ -427,6 +480,9 @@ class MysqlDumpPDO implements MysqlDumpInterface
427
  $query = $this->queryAdapter->show_create_table($tableName);
428
  foreach ($this->getConnection()->query($query) as $row) {
429
  if (isset($row['Create Table'])) {
 
 
 
430
  $this->fileAdapter->write("-- " .
431
  "--------------------------------------------------------" .
432
  "\n\n" .
@@ -437,7 +493,10 @@ class MysqlDumpPDO implements MysqlDumpInterface
437
  $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
438
  }
439
 
440
- $this->fileAdapter->write($row['Create Table'] . ";\n\n");
 
 
 
441
 
442
  return true;
443
  }
@@ -452,12 +511,6 @@ class MysqlDumpPDO implements MysqlDumpInterface
452
  */
453
  protected function listValues($tableName)
454
  {
455
- $this->fileAdapter->write(
456
- "--\n" .
457
- "-- Dumping data for table `$tableName`\n" .
458
- "--\n\n"
459
- );
460
-
461
  $insertFirst = true;
462
  $lineSize = 0;
463
  $query = "SELECT * FROM `$tableName` ";
@@ -470,10 +523,22 @@ class MysqlDumpPDO implements MysqlDumpInterface
470
  }
471
  }
472
 
 
 
 
 
 
 
 
 
 
473
  // Generate insert statements
474
  foreach ($this->getConnection()->query($query, PDO::FETCH_NUM) as $row) {
475
  $items = array();
476
  foreach ($row as $value) {
 
 
 
477
  $items[] = is_null($value) ? 'NULL' : $this->getConnection()->quote($value);;
478
  }
479
 
@@ -494,4 +559,20 @@ class MysqlDumpPDO implements MysqlDumpInterface
494
  $this->fileAdapter->write(";\n");
495
  }
496
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  }
67
 
68
  protected $connection = null;
69
 
70
+ protected $oldTablePrefix = null;
71
+
72
+ protected $newTablePrefix = null;
73
+
74
  protected $queryClauses = array();
75
 
76
  protected $includeTables = array();
145
  * Set output file name
146
  *
147
  * @param string $fileName Name of the output file
148
+ * @return MysqlDumpPDO
149
  */
150
  public function setFileName($fileName)
151
  {
164
  return $this->fileName;
165
  }
166
 
167
+ /**
168
+ * Set old table prefix
169
+ *
170
+ * @param string $prefix Name of the table prefix
171
+ * @return MysqlDumpPDO
172
+ */
173
+ public function setOldTablePrefix($prefix)
174
+ {
175
+ $this->oldTablePrefix = $prefix;
176
+
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Get old table prefix
182
+ *
183
+ * @return string
184
+ */
185
+ public function getOldTablePrefix()
186
+ {
187
+ return $this->oldTablePrefix;
188
+ }
189
+
190
+ /**
191
+ * Set new table prefix
192
+ *
193
+ * @param string $prefix Name of the table prefix
194
+ * @return MysqlDumpPDO
195
+ */
196
+ public function setNewTablePrefix($prefix)
197
+ {
198
+ $this->newTablePrefix = $prefix;
199
+
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Get new table prefix
205
+ *
206
+ * @return string
207
+ */
208
+ public function getNewTablePrefix()
209
+ {
210
+ return $this->newTablePrefix;
211
+ }
212
+
213
  /**
214
  * Set query clauses
215
  *
216
  * @param array $clauses List of SQL query clauses
217
+ * @return MysqlDumpPDO
218
  */
219
  public function setQueryClauses($clauses)
220
  {
237
  * Set include tables
238
  *
239
  * @param array $tables List of tables
240
+ * @return MysqlDumpPDO
241
  */
242
  public function setIncludeTables($tables)
243
  {
260
  * Set exclude tables
261
  *
262
  * @param array $tables List of tables
263
+ * @return MysqlDumpPDO
264
  */
265
  public function setExcludeTables($tables)
266
  {
283
  * Set no table data flag
284
  *
285
  * @param bool $flag Do not export table data
286
+ * @return MysqlDumpPDO
287
  */
288
  public function setNoTableData($flag)
289
  {
306
  * Set add drop table flag
307
  *
308
  * @param bool $flag Add drop table SQL clause
309
+ * @return MysqlDumpPDO
310
  */
311
  public function setAddDropTable($flag)
312
  {
329
  * Set extended insert flag
330
  *
331
  * @param bool $flag Add extended insert SQL clause
332
+ * @return MysqlDumpPDO
333
  */
334
  public function setExtendedInsert($flag)
335
  {
377
 
378
  // Read database file line by line
379
  while (($line = fgets($fileHandler)) !== false) {
380
+ // Replace table prefix
381
+ $line = $this->replaceTablePrefix($line, false);
382
+
383
  $query .= $line;
384
  if (preg_match('/;\s*$/', $line)) {
385
  try {
480
  $query = $this->queryAdapter->show_create_table($tableName);
481
  foreach ($this->getConnection()->query($query) as $row) {
482
  if (isset($row['Create Table'])) {
483
+ // Replace table prefix
484
+ $tableName = $this->replaceTablePrefix($tableName);
485
+
486
  $this->fileAdapter->write("-- " .
487
  "--------------------------------------------------------" .
488
  "\n\n" .
493
  $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
494
  }
495
 
496
+ // Replace table prefix
497
+ $createTable = $this->replaceTablePrefix($row['Create Table'], false);
498
+
499
+ $this->fileAdapter->write($createTable . ";\n\n");
500
 
501
  return true;
502
  }
511
  */
512
  protected function listValues($tableName)
513
  {
 
 
 
 
 
 
514
  $insertFirst = true;
515
  $lineSize = 0;
516
  $query = "SELECT * FROM `$tableName` ";
523
  }
524
  }
525
 
526
+ // Replace table prefix
527
+ $tableName = $this->replaceTablePrefix($tableName);
528
+
529
+ $this->fileAdapter->write(
530
+ "--\n" .
531
+ "-- Dumping data for table `$tableName`\n" .
532
+ "--\n\n"
533
+ );
534
+
535
  // Generate insert statements
536
  foreach ($this->getConnection()->query($query, PDO::FETCH_NUM) as $row) {
537
  $items = array();
538
  foreach ($row as $value) {
539
+ if ($value) {
540
+ $value = $this->replaceTablePrefix($value);
541
+ }
542
  $items[] = is_null($value) ? 'NULL' : $this->getConnection()->quote($value);;
543
  }
544
 
559
  $this->fileAdapter->write(";\n");
560
  }
561
  }
562
+
563
+ /**
564
+ * Replace table prefix (old to new one)
565
+ *
566
+ * @param string $tableName Name of table
567
+ * @param bool $start Match start of string, or start of line
568
+ * @return string
569
+ */
570
+ protected function replaceTablePrefix($tableName, $start = true) {
571
+ $pattern = preg_quote($this->getOldTablePrefix(), '/');
572
+ if ($start) {
573
+ return preg_replace('/^' . $pattern . '/i', $this->getNewTablePrefix(), $tableName);
574
+ } else {
575
+ return preg_replace('/' . $pattern . '/i', $this->getNewTablePrefix(), $tableName);
576
+ }
577
+ }
578
  }
lib/vendor/mysqldump-factory/mysqldump-factory/lib/MysqlDumpSQL.php CHANGED
@@ -67,6 +67,10 @@ class MysqlDumpSQL implements MysqlDumpInterface
67
 
68
  protected $connection = null;
69
 
 
 
 
 
70
  protected $queryClauses = array();
71
 
72
  protected $includeTables = array();
@@ -141,7 +145,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
141
  * Set output file name
142
  *
143
  * @param string $fileName Name of the output file
144
- * @return string
145
  */
146
  public function setFileName($fileName)
147
  {
@@ -160,11 +164,57 @@ class MysqlDumpSQL implements MysqlDumpInterface
160
  return $this->fileName;
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /**
164
  * Set query clauses
165
  *
166
  * @param array $clauses List of SQL query clauses
167
- * @return array
168
  */
169
  public function setQueryClauses($clauses)
170
  {
@@ -187,7 +237,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
187
  * Set include tables
188
  *
189
  * @param array $tables List of tables
190
- * @return array
191
  */
192
  public function setIncludeTables($tables)
193
  {
@@ -210,7 +260,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
210
  * Set exclude tables
211
  *
212
  * @param array $tables List of tables
213
- * @return array
214
  */
215
  public function setExcludeTables($tables)
216
  {
@@ -233,7 +283,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
233
  * Set no table data flag
234
  *
235
  * @param bool $flag Do not export table data
236
- * @return bool
237
  */
238
  public function setNoTableData($flag)
239
  {
@@ -256,7 +306,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
256
  * Set add drop table flag
257
  *
258
  * @param bool $flag Add drop table SQL clause
259
- * @return bool
260
  */
261
  public function setAddDropTable($flag)
262
  {
@@ -279,7 +329,7 @@ class MysqlDumpSQL implements MysqlDumpInterface
279
  * Set extended insert flag
280
  *
281
  * @param bool $flag Add extended insert SQL clause
282
- * @return bool
283
  */
284
  public function setExtendedInsert($flag)
285
  {
@@ -328,6 +378,9 @@ class MysqlDumpSQL implements MysqlDumpInterface
328
 
329
  // Read database file line by line
330
  while (($line = fgets($fileHandler)) !== false) {
 
 
 
331
  $query .= $line;
332
  if (preg_match('/;\s*$/', $line)) {
333
  // Run SQL query
@@ -419,6 +472,9 @@ class MysqlDumpSQL implements MysqlDumpInterface
419
  $result = mysql_query($query, $this->getConnection());
420
  while ($row = mysql_fetch_assoc($result)) {
421
  if (isset($row['Create Table'])) {
 
 
 
422
  $this->fileAdapter->write("-- " .
423
  "--------------------------------------------------------" .
424
  "\n\n" .
@@ -429,7 +485,10 @@ class MysqlDumpSQL implements MysqlDumpInterface
429
  $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
430
  }
431
 
432
- $this->fileAdapter->write($row['Create Table'] . ";\n\n");
 
 
 
433
 
434
  return true;
435
  }
@@ -444,12 +503,6 @@ class MysqlDumpSQL implements MysqlDumpInterface
444
  */
445
  protected function listValues($tableName)
446
  {
447
- $this->fileAdapter->write(
448
- "--\n" .
449
- "-- Dumping data for table `$tableName`\n" .
450
- "--\n\n"
451
- );
452
-
453
  $insertFirst = true;
454
  $lineSize = 0;
455
  $query = "SELECT * FROM `$tableName` ";
@@ -462,11 +515,23 @@ class MysqlDumpSQL implements MysqlDumpInterface
462
  }
463
  }
464
 
 
 
 
 
 
 
 
 
 
465
  // Generate insert statements
466
  $result = mysql_query($query, $this->getConnection());
467
  while ($row = mysql_fetch_row($result)) {
468
  $items = array();
469
  foreach ($row as $value) {
 
 
 
470
  $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($value) . "'";
471
  }
472
 
@@ -487,4 +552,20 @@ class MysqlDumpSQL implements MysqlDumpInterface
487
  $this->fileAdapter->write(";\n");
488
  }
489
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  }
67
 
68
  protected $connection = null;
69
 
70
+ protected $oldTablePrefix = null;
71
+
72
+ protected $newTablePrefix = null;
73
+
74
  protected $queryClauses = array();
75
 
76
  protected $includeTables = array();
145
  * Set output file name
146
  *
147
  * @param string $fileName Name of the output file
148
+ * @return MysqlDumpSQL
149
  */
150
  public function setFileName($fileName)
151
  {
164
  return $this->fileName;
165
  }
166
 
167
+ /**
168
+ * Set old table prefix
169
+ *
170
+ * @param string $prefix Name of the table prefix
171
+ * @return MysqlDumpSQL
172
+ */
173
+ public function setOldTablePrefix($prefix)
174
+ {
175
+ $this->oldTablePrefix = $prefix;
176
+
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Get old table prefix
182
+ *
183
+ * @return string
184
+ */
185
+ public function getOldTablePrefix()
186
+ {
187
+ return $this->oldTablePrefix;
188
+ }
189
+
190
+ /**
191
+ * Set new table prefix
192
+ *
193
+ * @param string $prefix Name of the table prefix
194
+ * @return MysqlDumpSQL
195
+ */
196
+ public function setNewTablePrefix($prefix)
197
+ {
198
+ $this->newTablePrefix = $prefix;
199
+
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * Get new table prefix
205
+ *
206
+ * @return string
207
+ */
208
+ public function getNewTablePrefix()
209
+ {
210
+ return $this->newTablePrefix;
211
+ }
212
+
213
  /**
214
  * Set query clauses
215
  *
216
  * @param array $clauses List of SQL query clauses
217
+ * @return MysqlDumpSQL
218
  */
219
  public function setQueryClauses($clauses)
220
  {
237
  * Set include tables
238
  *
239
  * @param array $tables List of tables
240
+ * @return MysqlDumpSQL
241
  */
242
  public function setIncludeTables($tables)
243
  {
260
  * Set exclude tables
261
  *
262
  * @param array $tables List of tables
263
+ * @return MysqlDumpSQL
264
  */
265
  public function setExcludeTables($tables)
266
  {
283
  * Set no table data flag
284
  *
285
  * @param bool $flag Do not export table data
286
+ * @return MysqlDumpSQL
287
  */
288
  public function setNoTableData($flag)
289
  {
306
  * Set add drop table flag
307
  *
308
  * @param bool $flag Add drop table SQL clause
309
+ * @return MysqlDumpSQL
310
  */
311
  public function setAddDropTable($flag)
312
  {
329
  * Set extended insert flag
330
  *
331
  * @param bool $flag Add extended insert SQL clause
332
+ * @return MysqlDumpSQL
333
  */
334
  public function setExtendedInsert($flag)
335
  {
378
 
379
  // Read database file line by line
380
  while (($line = fgets($fileHandler)) !== false) {
381
+ // Replace table prefix
382
+ $line = $this->replaceTablePrefix($line, false);
383
+
384
  $query .= $line;
385
  if (preg_match('/;\s*$/', $line)) {
386
  // Run SQL query
472
  $result = mysql_query($query, $this->getConnection());
473
  while ($row = mysql_fetch_assoc($result)) {
474
  if (isset($row['Create Table'])) {
475
+ // Replace table prefix
476
+ $tableName = $this->replaceTablePrefix($tableName);
477
+
478
  $this->fileAdapter->write("-- " .
479
  "--------------------------------------------------------" .
480
  "\n\n" .
485
  $this->fileAdapter->write("DROP TABLE IF EXISTS `$tableName`;\n\n");
486
  }
487
 
488
+ // Replace table prefix
489
+ $createTable = $this->replaceTablePrefix($row['Create Table'], false);
490
+
491
+ $this->fileAdapter->write($createTable . ";\n\n");
492
 
493
  return true;
494
  }
503
  */
504
  protected function listValues($tableName)
505
  {
 
 
 
 
 
 
506
  $insertFirst = true;
507
  $lineSize = 0;
508
  $query = "SELECT * FROM `$tableName` ";
515
  }
516
  }
517
 
518
+ // Replace table prefix
519
+ $tableName = $this->replaceTablePrefix($tableName);
520
+
521
+ $this->fileAdapter->write(
522
+ "--\n" .
523
+ "-- Dumping data for table `$tableName`\n" .
524
+ "--\n\n"
525
+ );
526
+
527
  // Generate insert statements
528
  $result = mysql_query($query, $this->getConnection());
529
  while ($row = mysql_fetch_row($result)) {
530
  $items = array();
531
  foreach ($row as $value) {
532
+ if ($value) {
533
+ $value = $this->replaceTablePrefix($value);
534
+ }
535
  $items[] = is_null($value) ? 'NULL' : "'" . mysql_real_escape_string($value) . "'";
536
  }
537
 
552
  $this->fileAdapter->write(";\n");
553
  }
554
  }
555
+
556
+ /**
557
+ * Replace table prefix (old to new one)
558
+ *
559
+ * @param string $tableName Name of table
560
+ * @param bool $start Match start of string, or start of line
561
+ * @return string
562
+ */
563
+ protected function replaceTablePrefix($tableName, $start = true) {
564
+ $pattern = preg_quote($this->getOldTablePrefix(), '/');
565
+ if ($start) {
566
+ return preg_replace('/^' . $pattern . '/i', $this->getNewTablePrefix(), $tableName);
567
+ } else {
568
+ return preg_replace('/' . $pattern . '/i', $this->getNewTablePrefix(), $tableName);
569
+ }
570
+ }
571
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: yani.iliev, bangelov, mirkov
3
  Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
4
  Requires at least: 3.3
5
  Tested up to: 3.8
6
- Stable tag: 1.2.0
7
  License: GPLv2 or later
8
 
9
  All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
@@ -59,9 +59,16 @@ All in One WP Plugin is the first plugin to offer true mobile experience on Word
59
  3. Plugin Menu
60
 
61
  == Changelog ==
 
 
 
 
 
 
 
62
 
63
  = 1.2.0 =
64
- * Increased upload limit of files from 150MB to 500MB
65
  * Use ZipArchive with fallback to PclZip (a few users notified us that they don’t have ZipArchive enabled on their servers)
66
  * Use PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17).
67
  * Support for PHP v5.2.17 and WordPress v3.3 and above.
3
  Tags: db migration, migration, wordpress migration, db backup, db restore, website backup, website restore, website migration, website deploy, wordpress deploy, db backup, database export, database serialization, database find replace
4
  Requires at least: 3.3
5
  Tested up to: 3.8
6
+ Stable tag: 1.2.1
7
  License: GPLv2 or later
8
 
9
  All-in-One WP Migration is the only tools that you will ever needs when you need to perform site migration of your WordPress blog.
59
  3. Plugin Menu
60
 
61
  == Changelog ==
62
+ = 1.2.1 =
63
+ * Fixed an issue when HTTP Error was shown on some hosts after import, credit to Michael Simon
64
+ * Fixed an issue when exporting databases with different prefix than wp_, credit to najtrox
65
+ * Fixed an issue when PDO is avalable but mysql driver for PDO is not, credit to Jaydesain69
66
+ * Delete a plugin specific option when uninstalling the plugin (clean after itself)
67
+ * Support is done via Zendesk
68
+ * Include WP Version and Plugin version in the feedback form
69
 
70
  = 1.2.0 =
71
+ * Increased upload limit of files from 128MB to 512MB
72
  * Use ZipArchive with fallback to PclZip (a few users notified us that they don’t have ZipArchive enabled on their servers)
73
  * Use PDO with fallback to mysql (a few users notified us that they dont have PDO enabled on their servers, mysql is deprecated as of PHP v5.5 but we are supporting PHP v5.2.17).
74
  * Support for PHP v5.2.17 and WordPress v3.3 and above.
uninstall.php CHANGED
@@ -16,12 +16,19 @@
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
 
 
 
 
 
19
  /**
20
  * Trigger Uninstall process only if WP_UNINSTALL_PLUGIN is defined
21
  */
22
  if ( defined( 'WP_UNINSTALL_PLUGIN' ) ) {
23
  global $wpdb, $wp_filesystem;
 
24
  // delete any options or other data stored in the database here
 
25
 
26
  // delete any files not located inside plugin's folder (if any)
27
  }
16
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
  */
18
 
19
+ // Include plugin bootstrap file
20
+ require_once dirname( __FILE__ ) .
21
+ DIRECTORY_SEPARATOR .
22
+ 'all-in-one-wp-migration.php';
23
+
24
  /**
25
  * Trigger Uninstall process only if WP_UNINSTALL_PLUGIN is defined
26
  */
27
  if ( defined( 'WP_UNINSTALL_PLUGIN' ) ) {
28
  global $wpdb, $wp_filesystem;
29
+
30
  // delete any options or other data stored in the database here
31
+ delete_option( Ai1wm_Export::EXPORT_LAST_OPTIONS );
32
 
33
  // delete any files not located inside plugin's folder (if any)
34
  }