Version Description
Added
- Support for Freemius framework
- Include table views between migrations
Download this release
Release Info
Developer | bangelov |
Plugin | All-in-One WP Migration |
Version | 7.13 |
Comparing to | |
See all releases |
Code changes from version 7.12 to 7.13
- all-in-one-wp-migration.php +1 -1
- constants.php +1 -1
- functions.php +14 -7
- lib/controller/class-ai1wm-main-controller.php +1 -0
- lib/model/export/class-ai1wm-export-config.php +3 -3
- lib/model/import/class-ai1wm-import-plugins.php +85 -0
- lib/vendor/servmask/database/class-ai1wm-database.php +319 -145
- loader.php +4 -0
- readme.txt +7 -1
all-in-one-wp-migration.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
|
6 |
* Author: ServMask
|
7 |
* Author URI: https://servmask.com/
|
8 |
-
* Version: 7.
|
9 |
* Text Domain: all-in-one-wp-migration
|
10 |
* Domain Path: /languages
|
11 |
* Network: True
|
5 |
* Description: Migration tool for all your blog data. Import or Export your blog content with a single click.
|
6 |
* Author: ServMask
|
7 |
* Author URI: https://servmask.com/
|
8 |
+
* Version: 7.13
|
9 |
* Text Domain: all-in-one-wp-migration
|
10 |
* Domain Path: /languages
|
11 |
* Network: True
|
constants.php
CHANGED
@@ -35,7 +35,7 @@ define( 'AI1WM_DEBUG', false );
|
|
35 |
// ==================
|
36 |
// = Plugin Version =
|
37 |
// ==================
|
38 |
-
define( 'AI1WM_VERSION', '7.
|
39 |
|
40 |
// ===============
|
41 |
// = Plugin Name =
|
35 |
// ==================
|
36 |
// = Plugin Version =
|
37 |
// ==================
|
38 |
+
define( 'AI1WM_VERSION', '7.13' );
|
39 |
|
40 |
// ===============
|
41 |
// = Plugin Name =
|
functions.php
CHANGED
@@ -1234,23 +1234,30 @@ function ai1wm_validate_theme_basename( $basename ) {
|
|
1234 |
* @return void
|
1235 |
*/
|
1236 |
function ai1wm_cache_flush() {
|
1237 |
-
// Initialize WP cache
|
1238 |
wp_cache_init();
|
1239 |
-
|
1240 |
-
// Flush WP cache
|
1241 |
wp_cache_flush();
|
1242 |
|
1243 |
-
//
|
1244 |
wp_cache_set( 'alloptions', array(), 'options' );
|
1245 |
wp_cache_set( 'notoptions', array(), 'options' );
|
1246 |
|
1247 |
-
//
|
|
|
|
|
|
|
|
|
|
|
1248 |
wp_cache_delete( 'alloptions', 'options' );
|
1249 |
wp_cache_delete( 'notoptions', 'options' );
|
1250 |
|
1251 |
-
//
|
1252 |
-
|
|
|
|
|
|
|
|
|
1253 |
remove_all_filters( 'sanitize_option_home' );
|
|
|
1254 |
}
|
1255 |
|
1256 |
/**
|
1234 |
* @return void
|
1235 |
*/
|
1236 |
function ai1wm_cache_flush() {
|
|
|
1237 |
wp_cache_init();
|
|
|
|
|
1238 |
wp_cache_flush();
|
1239 |
|
1240 |
+
// Reset WP options cache
|
1241 |
wp_cache_set( 'alloptions', array(), 'options' );
|
1242 |
wp_cache_set( 'notoptions', array(), 'options' );
|
1243 |
|
1244 |
+
// Reset WP sitemeta cache
|
1245 |
+
wp_cache_set( '1:notoptions', array(), 'site-options' );
|
1246 |
+
wp_cache_set( '1:ms_files_rewriting', false, 'site-options' );
|
1247 |
+
wp_cache_set( '1:active_sitewide_plugins', false, 'site-options' );
|
1248 |
+
|
1249 |
+
// Delete WP options cache
|
1250 |
wp_cache_delete( 'alloptions', 'options' );
|
1251 |
wp_cache_delete( 'notoptions', 'options' );
|
1252 |
|
1253 |
+
// Delete WP sitemeta cache
|
1254 |
+
wp_cache_delete( '1:notoptions', 'site-options' );
|
1255 |
+
wp_cache_delete( '1:ms_files_rewriting', 'site-options' );
|
1256 |
+
wp_cache_delete( '1:active_sitewide_plugins', 'site-options' );
|
1257 |
+
|
1258 |
+
// Remove WP options filter
|
1259 |
remove_all_filters( 'sanitize_option_home' );
|
1260 |
+
remove_all_filters( 'sanitize_option_siteurl' );
|
1261 |
}
|
1262 |
|
1263 |
/**
|
lib/controller/class-ai1wm-main-controller.php
CHANGED
@@ -171,6 +171,7 @@ class Ai1wm_Main_Controller {
|
|
171 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Content::execute', 250 );
|
172 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Mu_Plugins::execute', 270 );
|
173 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Database::execute', 300 );
|
|
|
174 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Done::execute', 350 );
|
175 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Clean::execute', 400 );
|
176 |
}
|
171 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Content::execute', 250 );
|
172 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Mu_Plugins::execute', 270 );
|
173 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Database::execute', 300 );
|
174 |
+
add_filter( 'ai1wm_import', 'Ai1wm_Import_Plugins::execute', 340 );
|
175 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Done::execute', 350 );
|
176 |
add_filter( 'ai1wm_import', 'Ai1wm_Import_Clean::execute', 400 );
|
177 |
}
|
lib/model/export/class-ai1wm-export-config.php
CHANGED
@@ -30,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
30 |
class Ai1wm_Export_Config {
|
31 |
|
32 |
public static function execute( $params ) {
|
33 |
-
global $wp_version, $wpdb;
|
34 |
|
35 |
// Set progress
|
36 |
Ai1wm_Status::info( __( 'Preparing configuration file...', AI1WM_PLUGIN_NAME ) );
|
@@ -135,10 +135,10 @@ class Ai1wm_Export_Config {
|
|
135 |
$config['WordPress'] = array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR, 'Plugins' => WP_PLUGIN_DIR, 'Themes' => get_theme_root(), 'Uploads' => ai1wm_get_uploads_dir() );
|
136 |
|
137 |
// Set database version
|
138 |
-
$config['Database'] = array( 'Version' => $mysql->version(), 'Charset' => DB_CHARSET, 'Collate' => DB_COLLATE );
|
139 |
|
140 |
// Set PHP version
|
141 |
-
$config['PHP'] = array( 'Version' => PHP_VERSION, 'Integer' => PHP_INT_SIZE );
|
142 |
|
143 |
// Set active plugins
|
144 |
$config['Plugins'] = array_values( array_diff( ai1wm_active_plugins(), ai1wm_active_servmask_plugins() ) );
|
30 |
class Ai1wm_Export_Config {
|
31 |
|
32 |
public static function execute( $params ) {
|
33 |
+
global $table_prefix, $wp_version, $wpdb;
|
34 |
|
35 |
// Set progress
|
36 |
Ai1wm_Status::info( __( 'Preparing configuration file...', AI1WM_PLUGIN_NAME ) );
|
135 |
$config['WordPress'] = array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR, 'Plugins' => WP_PLUGIN_DIR, 'Themes' => get_theme_root(), 'Uploads' => ai1wm_get_uploads_dir() );
|
136 |
|
137 |
// Set database version
|
138 |
+
$config['Database'] = array( 'Version' => $mysql->version(), 'Charset' => DB_CHARSET, 'Collate' => DB_COLLATE, 'Prefix' => $table_prefix );
|
139 |
|
140 |
// Set PHP version
|
141 |
+
$config['PHP'] = array( 'Version' => PHP_VERSION, 'System' => PHP_OS, 'Integer' => PHP_INT_SIZE );
|
142 |
|
143 |
// Set active plugins
|
144 |
$config['Plugins'] = array_values( array_diff( ai1wm_active_plugins(), ai1wm_active_servmask_plugins() ) );
|
lib/model/import/class-ai1wm-import-plugins.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Copyright (C) 2014-2019 ServMask Inc.
|
4 |
+
*
|
5 |
+
* This program is free software: you can redistribute it and/or modify
|
6 |
+
* it under the terms of the GNU General Public License as published by
|
7 |
+
* the Free Software Foundation, either version 3 of the License, or
|
8 |
+
* (at your option) any later version.
|
9 |
+
*
|
10 |
+
* This program is distributed in the hope that it will be useful,
|
11 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
* GNU General Public License for more details.
|
14 |
+
*
|
15 |
+
* You should have received a copy of the GNU General Public License
|
16 |
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
+
*
|
18 |
+
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
19 |
+
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
20 |
+
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
21 |
+
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
22 |
+
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
23 |
+
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
24 |
+
*/
|
25 |
+
|
26 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
27 |
+
die( 'Kangaroos cannot jump here' );
|
28 |
+
}
|
29 |
+
|
30 |
+
class Ai1wm_Import_Plugins {
|
31 |
+
|
32 |
+
public static function execute( $params, $mysql = null ) {
|
33 |
+
global $wpdb;
|
34 |
+
|
35 |
+
// Set progress
|
36 |
+
Ai1wm_Status::info( __( 'Activating plugins...', AI1WM_PLUGIN_NAME ) );
|
37 |
+
|
38 |
+
// Get database client
|
39 |
+
if ( is_null( $mysql ) ) {
|
40 |
+
if ( empty( $wpdb->use_mysqli ) ) {
|
41 |
+
$mysql = new Ai1wm_Database_Mysql( $wpdb );
|
42 |
+
} else {
|
43 |
+
$mysql = new Ai1wm_Database_Mysqli( $wpdb );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
$tables = $mysql->get_tables();
|
48 |
+
|
49 |
+
// Get base prefix
|
50 |
+
$base_prefix = ai1wm_table_prefix();
|
51 |
+
|
52 |
+
// Get mainsite prefix
|
53 |
+
$mainsite_prefix = ai1wm_table_prefix( 'mainsite' );
|
54 |
+
|
55 |
+
// Check WP sitemeta table exists
|
56 |
+
if ( in_array( "{$mainsite_prefix}sitemeta", $tables ) ) {
|
57 |
+
|
58 |
+
// Get fs_accounts option value (Freemius)
|
59 |
+
$result = $mysql->query( "SELECT meta_value FROM `{$mainsite_prefix}sitemeta` WHERE meta_key = 'fs_accounts'" );
|
60 |
+
if ( $row = $mysql->fetch_assoc( $result ) ) {
|
61 |
+
$fs_accounts = get_option( 'fs_accounts', array() );
|
62 |
+
$meta_value = maybe_unserialize( $row['meta_value'] );
|
63 |
+
|
64 |
+
// Update fs_accounts option value (Freemius)
|
65 |
+
if ( ( $fs_accounts = array_merge( $fs_accounts, $meta_value ) ) ) {
|
66 |
+
if ( isset( $fs_accounts['users'], $fs_accounts['sites'] ) ) {
|
67 |
+
update_option( 'fs_accounts', $fs_accounts );
|
68 |
+
} else {
|
69 |
+
delete_option( 'fs_accounts' );
|
70 |
+
delete_option( 'fs_dbg_accounts' );
|
71 |
+
delete_option( 'fs_active_plugins' );
|
72 |
+
delete_option( 'fs_api_cache' );
|
73 |
+
delete_option( 'fs_dbg_api_cache' );
|
74 |
+
delete_option( 'fs_debug_mode' );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
// Set progress
|
81 |
+
Ai1wm_Status::info( __( 'Done activating plugins.', AI1WM_PLUGIN_NAME ) );
|
82 |
+
|
83 |
+
return $params;
|
84 |
+
}
|
85 |
+
}
|
lib/vendor/servmask/database/class-ai1wm-database.php
CHANGED
@@ -519,6 +519,60 @@ abstract class Ai1wm_Database {
|
|
519 |
return $this->optimize_press;
|
520 |
}
|
521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
/**
|
523 |
* Get tables
|
524 |
*
|
@@ -527,53 +581,47 @@ abstract class Ai1wm_Database {
|
|
527 |
public function get_tables() {
|
528 |
$tables = array();
|
529 |
|
530 |
-
|
531 |
-
|
532 |
-
if ( isset( $row[0] ) && ( $table_name = $row[0] ) ) {
|
533 |
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
}
|
544 |
-
}
|
545 |
-
|
546 |
-
// Skip current table
|
547 |
-
if ( $include === false ) {
|
548 |
-
continue;
|
549 |
}
|
550 |
}
|
551 |
|
552 |
-
//
|
553 |
-
if ( $
|
554 |
-
|
|
|
|
|
555 |
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
$exclude = true;
|
560 |
-
break;
|
561 |
-
}
|
562 |
-
}
|
563 |
|
564 |
-
|
565 |
-
|
566 |
-
|
|
|
|
|
567 |
}
|
568 |
}
|
569 |
|
570 |
-
//
|
571 |
-
$
|
|
|
|
|
572 |
}
|
573 |
-
}
|
574 |
|
575 |
-
|
576 |
-
|
577 |
|
578 |
return $tables;
|
579 |
}
|
@@ -608,6 +656,9 @@ abstract class Ai1wm_Database {
|
|
608 |
// Get tables
|
609 |
$tables = $this->get_tables();
|
610 |
|
|
|
|
|
|
|
611 |
// Export tables
|
612 |
for ( ; $table_index < count( $tables ); ) {
|
613 |
|
@@ -617,163 +668,203 @@ abstract class Ai1wm_Database {
|
|
617 |
// Replace table name prefixes
|
618 |
$new_table_name = $this->replace_table_prefixes( $table_name, 0 );
|
619 |
|
620 |
-
//
|
621 |
-
if ( $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
|
623 |
-
|
624 |
-
|
625 |
|
626 |
-
|
627 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
628 |
|
629 |
// Get create table statement
|
630 |
-
|
631 |
|
632 |
-
|
633 |
-
|
634 |
|
635 |
-
|
636 |
-
|
637 |
|
638 |
-
|
639 |
-
|
640 |
|
641 |
-
|
642 |
-
|
643 |
|
644 |
-
|
645 |
-
|
646 |
-
}
|
647 |
|
648 |
-
|
649 |
-
|
650 |
|
651 |
-
|
652 |
-
|
653 |
|
654 |
-
|
655 |
-
|
|
|
656 |
|
657 |
-
|
|
|
658 |
|
659 |
-
//
|
660 |
-
|
661 |
|
662 |
-
|
663 |
-
|
664 |
-
foreach ( $primary_keys as $key ) {
|
665 |
-
$table_keys[] = sprintf( '`%s`', $key );
|
666 |
-
}
|
667 |
|
668 |
-
|
669 |
|
670 |
-
// Set
|
671 |
-
|
672 |
-
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
673 |
-
$table_where[] = $clause;
|
674 |
-
}
|
675 |
|
676 |
-
|
|
|
|
|
|
|
|
|
677 |
|
678 |
-
|
679 |
-
$query = sprintf( 'SELECT t1.* FROM `%s` AS t1 JOIN (SELECT %s FROM `%s` WHERE %s ORDER BY %s LIMIT %d, %d) AS t2 USING (%s)', $table_name, $table_keys, $table_name, $table_where, $table_keys, $table_offset, AI1WM_MAX_SELECT_RECORDS, $table_keys );
|
680 |
|
681 |
-
|
|
|
|
|
|
|
|
|
682 |
|
683 |
-
|
684 |
-
$table_keys = 1;
|
685 |
|
686 |
-
|
687 |
-
|
688 |
-
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
689 |
-
$table_where[] = $clause;
|
690 |
-
}
|
691 |
|
692 |
-
|
693 |
|
694 |
-
|
695 |
-
|
696 |
-
}
|
697 |
|
698 |
-
|
699 |
-
|
|
|
|
|
|
|
700 |
|
701 |
-
|
702 |
-
if ( $this->errno() === 1194 ) {
|
703 |
|
704 |
-
|
705 |
-
|
|
|
706 |
|
707 |
// Run SQL query
|
708 |
$result = $this->query( $query );
|
709 |
-
}
|
710 |
|
711 |
-
|
712 |
-
|
713 |
|
714 |
-
|
715 |
-
|
716 |
|
717 |
-
//
|
718 |
-
|
719 |
-
|
720 |
-
|
|
|
|
|
721 |
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
|
|
727 |
}
|
728 |
|
729 |
-
$items
|
730 |
-
|
|
|
|
|
|
|
|
|
731 |
|
732 |
-
|
733 |
-
|
734 |
|
735 |
-
|
736 |
-
|
737 |
|
738 |
-
|
739 |
-
|
740 |
|
741 |
-
|
742 |
-
|
743 |
|
744 |
-
|
745 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
|
747 |
// Write end of transaction
|
748 |
-
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES
|
749 |
ai1wm_write( $file_handler, "COMMIT;\n" );
|
750 |
}
|
751 |
-
}
|
752 |
-
} else {
|
753 |
|
754 |
-
|
755 |
-
|
756 |
-
ai1wm_write( $file_handler, "COMMIT;\n" );
|
757 |
-
}
|
758 |
-
|
759 |
-
// Set curent table index
|
760 |
-
$table_index++;
|
761 |
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
|
766 |
-
|
767 |
-
|
768 |
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
|
|
774 |
}
|
775 |
-
}
|
776 |
-
}
|
777 |
}
|
778 |
|
779 |
// Close file handler
|
@@ -929,8 +1020,13 @@ abstract class Ai1wm_Database {
|
|
929 |
* @return void
|
930 |
*/
|
931 |
public function flush() {
|
|
|
932 |
foreach ( $this->get_tables() as $table_name ) {
|
933 |
-
|
|
|
|
|
|
|
|
|
934 |
}
|
935 |
}
|
936 |
|
@@ -989,6 +1085,25 @@ abstract class Ai1wm_Database {
|
|
989 |
}
|
990 |
}
|
991 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
992 |
/**
|
993 |
* Get MySQL create table
|
994 |
*
|
@@ -1087,6 +1202,67 @@ abstract class Ai1wm_Database {
|
|
1087 |
return $column_types;
|
1088 |
}
|
1089 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1090 |
/**
|
1091 |
* Replace table prefixes
|
1092 |
*
|
@@ -1095,7 +1271,6 @@ abstract class Ai1wm_Database {
|
|
1095 |
* @return string
|
1096 |
*/
|
1097 |
protected function replace_table_prefixes( $input, $position = false ) {
|
1098 |
-
// Get table prefixes
|
1099 |
$search = $this->get_old_table_prefixes();
|
1100 |
$replace = $this->get_new_table_prefixes();
|
1101 |
|
@@ -1122,7 +1297,6 @@ abstract class Ai1wm_Database {
|
|
1122 |
* @return string
|
1123 |
*/
|
1124 |
protected function replace_column_prefixes( $input, $position = false ) {
|
1125 |
-
// Get column prefixes
|
1126 |
$search = $this->get_old_column_prefixes();
|
1127 |
$replace = $this->get_new_column_prefixes();
|
1128 |
|
519 |
return $this->optimize_press;
|
520 |
}
|
521 |
|
522 |
+
/**
|
523 |
+
* Get views
|
524 |
+
*
|
525 |
+
* @return array
|
526 |
+
*/
|
527 |
+
protected function get_views() {
|
528 |
+
static $views = null;
|
529 |
+
|
530 |
+
// Get views
|
531 |
+
if ( is_null( $views ) ) {
|
532 |
+
$views = array();
|
533 |
+
|
534 |
+
// Loop over views
|
535 |
+
$result = $this->query( "SHOW FULL TABLES FROM `{$this->wpdb->dbname}` WHERE `Table_type` = 'VIEW'" );
|
536 |
+
while ( $row = $this->fetch_row( $result ) ) {
|
537 |
+
if ( isset( $row[0] ) ) {
|
538 |
+
$views[] = $row[0];
|
539 |
+
}
|
540 |
+
}
|
541 |
+
|
542 |
+
// Close result cursor
|
543 |
+
$this->free_result( $result );
|
544 |
+
}
|
545 |
+
|
546 |
+
return $views;
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Get base tables
|
551 |
+
*
|
552 |
+
* @return array
|
553 |
+
*/
|
554 |
+
protected function get_base_tables() {
|
555 |
+
static $base_tables = null;
|
556 |
+
|
557 |
+
// Get base tables
|
558 |
+
if ( is_null( $base_tables ) ) {
|
559 |
+
$base_tables = array();
|
560 |
+
|
561 |
+
// Loop over base tables
|
562 |
+
$result = $this->query( "SHOW FULL TABLES FROM `{$this->wpdb->dbname}` WHERE `Table_type` = 'BASE TABLE'" );
|
563 |
+
while ( $row = $this->fetch_row( $result ) ) {
|
564 |
+
if ( isset( $row[0] ) ) {
|
565 |
+
$base_tables[] = $row[0];
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
// Close result cursor
|
570 |
+
$this->free_result( $result );
|
571 |
+
}
|
572 |
+
|
573 |
+
return $base_tables;
|
574 |
+
}
|
575 |
+
|
576 |
/**
|
577 |
* Get tables
|
578 |
*
|
581 |
public function get_tables() {
|
582 |
$tables = array();
|
583 |
|
584 |
+
// Get base tables and views
|
585 |
+
foreach ( array_merge( $this->get_base_tables(), $this->get_views() ) as $table_name ) {
|
|
|
586 |
|
587 |
+
// Include table prefixes
|
588 |
+
if ( $this->get_include_table_prefixes() ) {
|
589 |
+
$include = false;
|
590 |
|
591 |
+
// Check table prefixes
|
592 |
+
foreach ( $this->get_include_table_prefixes() as $prefix ) {
|
593 |
+
if ( stripos( $table_name, $prefix ) === 0 ) {
|
594 |
+
$include = true;
|
595 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
596 |
}
|
597 |
}
|
598 |
|
599 |
+
// Skip current table
|
600 |
+
if ( $include === false ) {
|
601 |
+
continue;
|
602 |
+
}
|
603 |
+
}
|
604 |
|
605 |
+
// Exclude table prefixes
|
606 |
+
if ( $this->get_exclude_table_prefixes() ) {
|
607 |
+
$exclude = false;
|
|
|
|
|
|
|
|
|
608 |
|
609 |
+
// Check table prefixes
|
610 |
+
foreach ( $this->get_exclude_table_prefixes() as $prefix ) {
|
611 |
+
if ( stripos( $table_name, $prefix ) === 0 ) {
|
612 |
+
$exclude = true;
|
613 |
+
break;
|
614 |
}
|
615 |
}
|
616 |
|
617 |
+
// Skip current table
|
618 |
+
if ( $exclude === true ) {
|
619 |
+
continue;
|
620 |
+
}
|
621 |
}
|
|
|
622 |
|
623 |
+
$tables[] = $table_name;
|
624 |
+
}
|
625 |
|
626 |
return $tables;
|
627 |
}
|
656 |
// Get tables
|
657 |
$tables = $this->get_tables();
|
658 |
|
659 |
+
// Get views
|
660 |
+
$views = $this->get_views();
|
661 |
+
|
662 |
// Export tables
|
663 |
for ( ; $table_index < count( $tables ); ) {
|
664 |
|
668 |
// Replace table name prefixes
|
669 |
$new_table_name = $this->replace_table_prefixes( $table_name, 0 );
|
670 |
|
671 |
+
// Loop over tables and views
|
672 |
+
if ( in_array( $table_name, $views ) ) {
|
673 |
+
|
674 |
+
// Get create view statement
|
675 |
+
if ( $table_offset === 0 ) {
|
676 |
+
|
677 |
+
// Write view drop statement
|
678 |
+
$drop_view = "\nDROP VIEW IF EXISTS `{$new_table_name}`;\n";
|
679 |
+
|
680 |
+
// Write drop view statement
|
681 |
+
ai1wm_write( $file_handler, $drop_view );
|
682 |
|
683 |
+
// Get create view statement
|
684 |
+
$create_view = $this->get_create_view( $table_name );
|
685 |
|
686 |
+
// Replace create view name
|
687 |
+
$create_view = $this->replace_view_name( $create_view, $table_name, $new_table_name );
|
688 |
+
|
689 |
+
// Replace create view identifiers
|
690 |
+
$create_view = $this->replace_view_identifiers( $create_view );
|
691 |
+
|
692 |
+
// Replace create view options
|
693 |
+
$create_view = $this->replace_view_options( $create_view );
|
694 |
+
|
695 |
+
// Write create view statement
|
696 |
+
ai1wm_write( $file_handler, $create_view );
|
697 |
+
|
698 |
+
// Write end of statement
|
699 |
+
ai1wm_write( $file_handler, ";\n\n" );
|
700 |
+
}
|
701 |
+
|
702 |
+
// Set curent table index
|
703 |
+
$table_index++;
|
704 |
+
|
705 |
+
// Set current table offset
|
706 |
+
$table_offset = 0;
|
707 |
+
|
708 |
+
} else {
|
709 |
|
710 |
// Get create table statement
|
711 |
+
if ( $table_offset === 0 ) {
|
712 |
|
713 |
+
// Write table drop statement
|
714 |
+
$drop_table = "\nDROP TABLE IF EXISTS `{$new_table_name}`;\n";
|
715 |
|
716 |
+
// Write table statement
|
717 |
+
ai1wm_write( $file_handler, $drop_table );
|
718 |
|
719 |
+
// Get create table statement
|
720 |
+
$create_table = $this->get_create_table( $table_name );
|
721 |
|
722 |
+
// Replace create table name
|
723 |
+
$create_table = $this->replace_table_name( $create_table, $table_name, $new_table_name );
|
724 |
|
725 |
+
// Replace create table constraints
|
726 |
+
$create_table = $this->replace_table_constraints( $create_table );
|
|
|
727 |
|
728 |
+
// Replace create table options
|
729 |
+
$create_table = $this->replace_table_options( $create_table );
|
730 |
|
731 |
+
// Write create table statement
|
732 |
+
ai1wm_write( $file_handler, $create_table );
|
733 |
|
734 |
+
// Write end of statement
|
735 |
+
ai1wm_write( $file_handler, ";\n\n" );
|
736 |
+
}
|
737 |
|
738 |
+
// Get primary keys
|
739 |
+
$primary_keys = $this->get_primary_keys( $table_name );
|
740 |
|
741 |
+
// Get table columns
|
742 |
+
$table_columns = $this->get_column_types( $table_name );
|
743 |
|
744 |
+
// Get prefix columns
|
745 |
+
$prefix_columns = $this->get_table_prefix_columns( $table_name );
|
|
|
|
|
|
|
746 |
|
747 |
+
do {
|
748 |
|
749 |
+
// Set query
|
750 |
+
if ( $primary_keys ) {
|
|
|
|
|
|
|
751 |
|
752 |
+
// Set table keys
|
753 |
+
$table_keys = array();
|
754 |
+
foreach ( $primary_keys as $key ) {
|
755 |
+
$table_keys[] = sprintf( '`%s`', $key );
|
756 |
+
}
|
757 |
|
758 |
+
$table_keys = implode( ', ', $table_keys );
|
|
|
759 |
|
760 |
+
// Set table where clauses
|
761 |
+
$table_where = array( 1 );
|
762 |
+
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
763 |
+
$table_where[] = $clause;
|
764 |
+
}
|
765 |
|
766 |
+
$table_where = implode( ' AND ', $table_where );
|
|
|
767 |
|
768 |
+
// Set query with offset and rows count
|
769 |
+
$query = sprintf( 'SELECT t1.* FROM `%s` AS t1 JOIN (SELECT %s FROM `%s` WHERE %s ORDER BY %s LIMIT %d, %d) AS t2 USING (%s)', $table_name, $table_keys, $table_name, $table_where, $table_keys, $table_offset, AI1WM_MAX_SELECT_RECORDS, $table_keys );
|
|
|
|
|
|
|
770 |
|
771 |
+
} else {
|
772 |
|
773 |
+
// Set table keys
|
774 |
+
$table_keys = 1;
|
|
|
775 |
|
776 |
+
// Set table where clauses
|
777 |
+
$table_where = array( 1 );
|
778 |
+
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
779 |
+
$table_where[] = $clause;
|
780 |
+
}
|
781 |
|
782 |
+
$table_where = implode( ' AND ', $table_where );
|
|
|
783 |
|
784 |
+
// Set query with offset and rows count
|
785 |
+
$query = sprintf( 'SELECT * FROM `%s` WHERE %s ORDER BY %s LIMIT %d, %d', $table_name, $table_where, $table_keys, $table_offset, AI1WM_MAX_SELECT_RECORDS );
|
786 |
+
}
|
787 |
|
788 |
// Run SQL query
|
789 |
$result = $this->query( $query );
|
|
|
790 |
|
791 |
+
// Repair table data
|
792 |
+
if ( $this->errno() === 1194 ) {
|
793 |
|
794 |
+
// Current table is marked as crashed and should be repaired
|
795 |
+
$this->repair_table( $table_name );
|
796 |
|
797 |
+
// Run SQL query
|
798 |
+
$result = $this->query( $query );
|
799 |
+
}
|
800 |
+
|
801 |
+
// Generate insert statements
|
802 |
+
if ( $num_rows = $this->num_rows( $result ) ) {
|
803 |
|
804 |
+
// Loop over table rows
|
805 |
+
while ( $row = $this->fetch_assoc( $result ) ) {
|
806 |
+
|
807 |
+
// Write start transaction
|
808 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES === 0 ) {
|
809 |
+
ai1wm_write( $file_handler, "START TRANSACTION;\n" );
|
810 |
}
|
811 |
|
812 |
+
$items = array();
|
813 |
+
foreach ( $row as $key => $value ) {
|
814 |
+
// Replace table prefix columns
|
815 |
+
if ( isset( $prefix_columns[ strtolower( $key ) ] ) ) {
|
816 |
+
$value = $this->replace_column_prefixes( $value, 0 );
|
817 |
+
}
|
818 |
|
819 |
+
$items[] = $this->prepare_table_values( $value, $table_columns[ strtolower( $key ) ] );
|
820 |
+
}
|
821 |
|
822 |
+
// Set table values
|
823 |
+
$table_values = implode( ',', $items );
|
824 |
|
825 |
+
// Set insert statement
|
826 |
+
$table_insert = "INSERT INTO `{$new_table_name}` VALUES ({$table_values});\n";
|
827 |
|
828 |
+
// Write insert statement
|
829 |
+
ai1wm_write( $file_handler, $table_insert );
|
830 |
|
831 |
+
// Set current table offset
|
832 |
+
$table_offset++;
|
833 |
+
|
834 |
+
// Set current table rows
|
835 |
+
$table_rows++;
|
836 |
+
|
837 |
+
// Write end of transaction
|
838 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES === 0 ) {
|
839 |
+
ai1wm_write( $file_handler, "COMMIT;\n" );
|
840 |
+
}
|
841 |
+
}
|
842 |
+
} else {
|
843 |
|
844 |
// Write end of transaction
|
845 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES !== 0 ) {
|
846 |
ai1wm_write( $file_handler, "COMMIT;\n" );
|
847 |
}
|
|
|
|
|
848 |
|
849 |
+
// Set curent table index
|
850 |
+
$table_index++;
|
|
|
|
|
|
|
|
|
|
|
851 |
|
852 |
+
// Set current table offset
|
853 |
+
$table_offset = 0;
|
854 |
+
}
|
855 |
|
856 |
+
// Close result cursor
|
857 |
+
$this->free_result( $result );
|
858 |
|
859 |
+
// Time elapsed
|
860 |
+
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
861 |
+
if ( ( microtime( true ) - $start ) > $timeout ) {
|
862 |
+
$completed = false;
|
863 |
+
break 2;
|
864 |
+
}
|
865 |
}
|
866 |
+
} while ( $num_rows > 0 );
|
867 |
+
}
|
868 |
}
|
869 |
|
870 |
// Close file handler
|
1020 |
* @return void
|
1021 |
*/
|
1022 |
public function flush() {
|
1023 |
+
$views = $this->get_views();
|
1024 |
foreach ( $this->get_tables() as $table_name ) {
|
1025 |
+
if ( in_array( $table_name, $views ) ) {
|
1026 |
+
$this->query( "DROP VIEW IF EXISTS `{$table_name}`" );
|
1027 |
+
} else {
|
1028 |
+
$this->query( "DROP TABLE IF EXISTS `{$table_name}`" );
|
1029 |
+
}
|
1030 |
}
|
1031 |
}
|
1032 |
|
1085 |
}
|
1086 |
}
|
1087 |
|
1088 |
+
/**
|
1089 |
+
* Get MySQL create view
|
1090 |
+
*
|
1091 |
+
* @param string $view_name View name
|
1092 |
+
* @return string
|
1093 |
+
*/
|
1094 |
+
protected function get_create_view( $view_name ) {
|
1095 |
+
$result = $this->query( "SHOW CREATE VIEW `{$view_name}`" );
|
1096 |
+
$row = $this->fetch_assoc( $result );
|
1097 |
+
|
1098 |
+
// Close result cursor
|
1099 |
+
$this->free_result( $result );
|
1100 |
+
|
1101 |
+
// Get create table
|
1102 |
+
if ( isset( $row['Create View'] ) ) {
|
1103 |
+
return $row['Create View'];
|
1104 |
+
}
|
1105 |
+
}
|
1106 |
+
|
1107 |
/**
|
1108 |
* Get MySQL create table
|
1109 |
*
|
1202 |
return $column_types;
|
1203 |
}
|
1204 |
|
1205 |
+
/**
|
1206 |
+
* Replace table name
|
1207 |
+
*
|
1208 |
+
* @param string $input Table value
|
1209 |
+
* @param string $old_table_name Old table name
|
1210 |
+
* @param string $new_table_name New table name
|
1211 |
+
* @return string
|
1212 |
+
*/
|
1213 |
+
protected function replace_table_name( $input, $old_table_name, $new_table_name ) {
|
1214 |
+
$position = stripos( $input, "`$old_table_name`" );
|
1215 |
+
if ( $position !== false ) {
|
1216 |
+
$input = substr_replace( $input, "`$new_table_name`", $position, strlen( "`$old_table_name`" ) );
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
return $input;
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
/**
|
1223 |
+
* Replace view name
|
1224 |
+
*
|
1225 |
+
* @param string $input View value
|
1226 |
+
* @param string $old_view_name Old view name
|
1227 |
+
* @param string $new_view_name New view name
|
1228 |
+
* @return string
|
1229 |
+
*/
|
1230 |
+
protected function replace_view_name( $input, $old_view_name, $new_view_name ) {
|
1231 |
+
$position = stripos( $input, "`$old_view_name`" );
|
1232 |
+
if ( $position !== false ) {
|
1233 |
+
$input = substr_replace( $input, "`$new_view_name`", $position, strlen( "`$old_view_name`" ) );
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
return $input;
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
/**
|
1240 |
+
* Replace view identifiers
|
1241 |
+
*
|
1242 |
+
* @param string $input Table value
|
1243 |
+
* @return string
|
1244 |
+
*/
|
1245 |
+
protected function replace_view_identifiers( $input ) {
|
1246 |
+
$base_tables = $this->get_base_tables();
|
1247 |
+
foreach ( $base_tables as $table_name ) {
|
1248 |
+
if ( ( $new_table_name = $this->replace_table_prefixes( $table_name, 0 ) ) ) {
|
1249 |
+
$input = str_ireplace( "`$table_name`", "`$new_table_name`", $input );
|
1250 |
+
}
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
return $input;
|
1254 |
+
}
|
1255 |
+
|
1256 |
+
/**
|
1257 |
+
* Replace view options
|
1258 |
+
*
|
1259 |
+
* @param string $input Table value
|
1260 |
+
* @return string
|
1261 |
+
*/
|
1262 |
+
protected function replace_view_options( $input ) {
|
1263 |
+
return preg_replace( '/CREATE(.+?)VIEW/i', 'CREATE VIEW', $input );
|
1264 |
+
}
|
1265 |
+
|
1266 |
/**
|
1267 |
* Replace table prefixes
|
1268 |
*
|
1271 |
* @return string
|
1272 |
*/
|
1273 |
protected function replace_table_prefixes( $input, $position = false ) {
|
|
|
1274 |
$search = $this->get_old_table_prefixes();
|
1275 |
$replace = $this->get_new_table_prefixes();
|
1276 |
|
1297 |
* @return string
|
1298 |
*/
|
1299 |
protected function replace_column_prefixes( $input, $position = false ) {
|
|
|
1300 |
$search = $this->get_old_column_prefixes();
|
1301 |
$replace = $this->get_new_column_prefixes();
|
1302 |
|
loader.php
CHANGED
@@ -297,6 +297,10 @@ require_once AI1WM_IMPORT_PATH .
|
|
297 |
DIRECTORY_SEPARATOR .
|
298 |
'class-ai1wm-import-database.php';
|
299 |
|
|
|
|
|
|
|
|
|
300 |
require_once AI1WM_IMPORT_PATH .
|
301 |
DIRECTORY_SEPARATOR .
|
302 |
'class-ai1wm-import-done.php';
|
297 |
DIRECTORY_SEPARATOR .
|
298 |
'class-ai1wm-import-database.php';
|
299 |
|
300 |
+
require_once AI1WM_IMPORT_PATH .
|
301 |
+
DIRECTORY_SEPARATOR .
|
302 |
+
'class-ai1wm-import-plugins.php';
|
303 |
+
|
304 |
require_once AI1WM_IMPORT_PATH .
|
305 |
DIRECTORY_SEPARATOR .
|
306 |
'class-ai1wm-import-done.php';
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: move, transfer, copy, migrate, backup, clone, restore, db migration, wordp
|
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.2.17
|
7 |
-
Stable tag: 7.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
|
@@ -108,6 +108,12 @@ Alternatively you can download the plugin using the download button on this page
|
|
108 |
All-in-One WP Migration **asks for your consent** to collect **requester's email address** when filling plugin's contact form. [GDPR Compliant Privacy Policy](https://www.iubenda.com/privacy-policy/946881)
|
109 |
|
110 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
= 7.12 =
|
112 |
**Added**
|
113 |
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 5.3
|
6 |
Requires PHP: 5.2.17
|
7 |
+
Stable tag: 7.13
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable.
|
108 |
All-in-One WP Migration **asks for your consent** to collect **requester's email address** when filling plugin's contact form. [GDPR Compliant Privacy Policy](https://www.iubenda.com/privacy-policy/946881)
|
109 |
|
110 |
== Changelog ==
|
111 |
+
= 7.13 =
|
112 |
+
**Added**
|
113 |
+
|
114 |
+
* Support for Freemius framework
|
115 |
+
* Include table views between migrations
|
116 |
+
|
117 |
= 7.12 =
|
118 |
**Added**
|
119 |
|