Version Description
Added
- Improved database export
Download this release
Release Info
| Developer | bangelov |
| Plugin | |
| Version | 7.33 |
| Comparing to | |
| See all releases | |
Code changes from version 7.32 to 7.33
- all-in-one-wp-migration.php +1 -1
- constants.php +6 -1
- functions.php +22 -0
- lib/model/class-ai1wm-extensions.php +1 -1
- lib/model/export/class-ai1wm-export-config.php +3 -0
- lib/model/export/class-ai1wm-export-database.php +14 -1
- lib/vendor/servmask/database/class-ai1wm-database.php +160 -152
- readme.txt +6 -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.33
|
| 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 =
|
|
@@ -439,6 +439,11 @@ define( 'AI1WM_BACKUPS_WEBCONFIG', AI1WM_BACKUPS_PATH . DIRECTORY_SEPARATOR . 'w
|
|
| 439 |
// ============================
|
| 440 |
define( 'AI1WM_WORDPRESS_HTACCESS', ABSPATH . DIRECTORY_SEPARATOR . '.htaccess' );
|
| 441 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
// ================================
|
| 443 |
// = WP Migration Plugin Base Dir =
|
| 444 |
// ================================
|
| 35 |
// ==================
|
| 36 |
// = Plugin Version =
|
| 37 |
// ==================
|
| 38 |
+
define( 'AI1WM_VERSION', '7.33' );
|
| 39 |
|
| 40 |
// ===============
|
| 41 |
// = Plugin Name =
|
| 439 |
// ============================
|
| 440 |
define( 'AI1WM_WORDPRESS_HTACCESS', ABSPATH . DIRECTORY_SEPARATOR . '.htaccess' );
|
| 441 |
|
| 442 |
+
// =============================
|
| 443 |
+
// = WordPress web.config File =
|
| 444 |
+
// =============================
|
| 445 |
+
define( 'AI1WM_WORDPRESS_WEBCONFIG', ABSPATH . DIRECTORY_SEPARATOR . 'web.config' );
|
| 446 |
+
|
| 447 |
// ================================
|
| 448 |
// = WP Migration Plugin Base Dir =
|
| 449 |
// ================================
|
functions.php
CHANGED
|
@@ -1827,3 +1827,25 @@ function ai1wm_got_url_permalinks() {
|
|
| 1827 |
|
| 1828 |
return true;
|
| 1829 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1827 |
|
| 1828 |
return true;
|
| 1829 |
}
|
| 1830 |
+
|
| 1831 |
+
/**
|
| 1832 |
+
* Get .htaccess file content
|
| 1833 |
+
*
|
| 1834 |
+
* @return string
|
| 1835 |
+
*/
|
| 1836 |
+
function ai1wm_get_htaccess() {
|
| 1837 |
+
if ( is_file( AI1WM_WORDPRESS_HTACCESS ) ) {
|
| 1838 |
+
return @file_get_contents( AI1WM_WORDPRESS_HTACCESS );
|
| 1839 |
+
}
|
| 1840 |
+
}
|
| 1841 |
+
|
| 1842 |
+
/**
|
| 1843 |
+
* Get web.config file content
|
| 1844 |
+
*
|
| 1845 |
+
* @return string
|
| 1846 |
+
*/
|
| 1847 |
+
function ai1wm_get_webconfig() {
|
| 1848 |
+
if ( is_file( AI1WM_WORDPRESS_WEBCONFIG ) ) {
|
| 1849 |
+
return @file_get_contents( AI1WM_WORDPRESS_WEBCONFIG );
|
| 1850 |
+
}
|
| 1851 |
+
}
|
lib/model/class-ai1wm-extensions.php
CHANGED
|
@@ -214,7 +214,7 @@ class Ai1wm_Extensions {
|
|
| 214 |
'about' => AI1WMME_PLUGIN_ABOUT,
|
| 215 |
'basename' => AI1WMME_PLUGIN_BASENAME,
|
| 216 |
'version' => AI1WMME_VERSION,
|
| 217 |
-
'requires' => '4.
|
| 218 |
'short' => AI1WMME_PLUGIN_SHORT,
|
| 219 |
);
|
| 220 |
}
|
| 214 |
'about' => AI1WMME_PLUGIN_ABOUT,
|
| 215 |
'basename' => AI1WMME_PLUGIN_BASENAME,
|
| 216 |
'version' => AI1WMME_VERSION,
|
| 217 |
+
'requires' => '4.3',
|
| 218 |
'short' => AI1WMME_PLUGIN_SHORT,
|
| 219 |
);
|
| 220 |
}
|
lib/model/export/class-ai1wm-export-config.php
CHANGED
|
@@ -155,6 +155,9 @@ class Ai1wm_Export_Config {
|
|
| 155 |
// Set upload URL path
|
| 156 |
$config['UploadsURL'] = get_option( 'upload_url_path' );
|
| 157 |
|
|
|
|
|
|
|
|
|
|
| 158 |
// Save package.json file
|
| 159 |
$handle = ai1wm_open( ai1wm_package_path( $params ), 'w' );
|
| 160 |
ai1wm_write( $handle, json_encode( $config ) );
|
| 155 |
// Set upload URL path
|
| 156 |
$config['UploadsURL'] = get_option( 'upload_url_path' );
|
| 157 |
|
| 158 |
+
// Set server info
|
| 159 |
+
$config['Server'] = array( '.htaccess' => base64_encode( ai1wm_get_htaccess() ), 'web.config' => base64_encode( ai1wm_get_webconfig() ) );
|
| 160 |
+
|
| 161 |
// Save package.json file
|
| 162 |
$handle = ai1wm_open( ai1wm_package_path( $params ), 'w' );
|
| 163 |
ai1wm_write( $handle, json_encode( $config ) );
|
lib/model/export/class-ai1wm-export-database.php
CHANGED
|
@@ -37,6 +37,13 @@ class Ai1wm_Export_Database {
|
|
| 37 |
return $params;
|
| 38 |
}
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
// Set table index
|
| 41 |
if ( isset( $params['table_index'] ) ) {
|
| 42 |
$table_index = (int) $params['table_index'];
|
|
@@ -149,11 +156,14 @@ class Ai1wm_Export_Database {
|
|
| 149 |
->set_table_prefix_columns( ai1wm_table_prefix() . 'usermeta', array( 'meta_key' ) );
|
| 150 |
|
| 151 |
// Export database
|
| 152 |
-
if ( $mysql->export( ai1wm_database_path( $params ), $table_index, $table_offset, $table_rows ) ) {
|
| 153 |
|
| 154 |
// Set progress
|
| 155 |
Ai1wm_Status::info( __( 'Done exporting database.', AI1WM_PLUGIN_NAME ) );
|
| 156 |
|
|
|
|
|
|
|
|
|
|
| 157 |
// Unset table index
|
| 158 |
unset( $params['table_index'] );
|
| 159 |
|
|
@@ -180,6 +190,9 @@ class Ai1wm_Export_Database {
|
|
| 180 |
// Set progress
|
| 181 |
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%d%% complete<br />%s records saved', AI1WM_PLUGIN_NAME ), $progress, number_format_i18n( $table_rows ) ) );
|
| 182 |
|
|
|
|
|
|
|
|
|
|
| 183 |
// Set table index
|
| 184 |
$params['table_index'] = $table_index;
|
| 185 |
|
| 37 |
return $params;
|
| 38 |
}
|
| 39 |
|
| 40 |
+
// Set query offset
|
| 41 |
+
if ( isset( $params['query_offset'] ) ) {
|
| 42 |
+
$query_offset = (int) $params['query_offset'];
|
| 43 |
+
} else {
|
| 44 |
+
$query_offset = 0;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
// Set table index
|
| 48 |
if ( isset( $params['table_index'] ) ) {
|
| 49 |
$table_index = (int) $params['table_index'];
|
| 156 |
->set_table_prefix_columns( ai1wm_table_prefix() . 'usermeta', array( 'meta_key' ) );
|
| 157 |
|
| 158 |
// Export database
|
| 159 |
+
if ( $mysql->export( ai1wm_database_path( $params ), $query_offset, $table_index, $table_offset, $table_rows ) ) {
|
| 160 |
|
| 161 |
// Set progress
|
| 162 |
Ai1wm_Status::info( __( 'Done exporting database.', AI1WM_PLUGIN_NAME ) );
|
| 163 |
|
| 164 |
+
// Unset query offset
|
| 165 |
+
unset( $params['query_offset'] );
|
| 166 |
+
|
| 167 |
// Unset table index
|
| 168 |
unset( $params['table_index'] );
|
| 169 |
|
| 190 |
// Set progress
|
| 191 |
Ai1wm_Status::info( sprintf( __( 'Exporting database...<br />%d%% complete<br />%s records saved', AI1WM_PLUGIN_NAME ), $progress, number_format_i18n( $table_rows ) ) );
|
| 192 |
|
| 193 |
+
// Set query offset
|
| 194 |
+
$params['query_offset'] = $query_offset;
|
| 195 |
+
|
| 196 |
// Set table index
|
| 197 |
$params['table_index'] = $table_index;
|
| 198 |
|
lib/vendor/servmask/database/class-ai1wm-database.php
CHANGED
|
@@ -717,19 +717,15 @@ abstract class Ai1wm_Database {
|
|
| 717 |
* Export database into a file
|
| 718 |
*
|
| 719 |
* @param string $file_name File name
|
|
|
|
| 720 |
* @param integer $table_index Table index
|
| 721 |
* @param integer $table_offset Table offset
|
| 722 |
* @param integer $table_rows Table rows
|
| 723 |
* @return boolean
|
| 724 |
*/
|
| 725 |
-
public function export( $file_name, &$table_index = 0, &$table_offset = 0, &$table_rows = 0 ) {
|
| 726 |
// Set file handler
|
| 727 |
-
$file_handler = ai1wm_open( $file_name, '
|
| 728 |
-
|
| 729 |
-
// Write headers
|
| 730 |
-
if ( $table_index === 0 ) {
|
| 731 |
-
ai1wm_write( $file_handler, $this->get_header() );
|
| 732 |
-
}
|
| 733 |
|
| 734 |
// Start time
|
| 735 |
$start = microtime( true );
|
|
@@ -746,217 +742,229 @@ abstract class Ai1wm_Database {
|
|
| 746 |
// Get views
|
| 747 |
$views = $this->get_views();
|
| 748 |
|
| 749 |
-
//
|
| 750 |
-
|
| 751 |
|
| 752 |
-
//
|
| 753 |
-
|
|
|
|
|
|
|
| 754 |
|
| 755 |
-
//
|
| 756 |
-
$
|
| 757 |
|
| 758 |
-
|
| 759 |
-
|
| 760 |
|
| 761 |
-
//
|
| 762 |
-
|
| 763 |
|
| 764 |
-
|
| 765 |
-
|
| 766 |
-
|
| 767 |
-
// Write drop view statement
|
| 768 |
-
ai1wm_write( $file_handler, $drop_view );
|
| 769 |
|
| 770 |
// Get create view statement
|
| 771 |
-
|
| 772 |
|
| 773 |
-
|
| 774 |
-
|
| 775 |
|
| 776 |
-
|
| 777 |
-
|
| 778 |
|
| 779 |
-
|
| 780 |
-
|
| 781 |
|
| 782 |
-
|
| 783 |
-
|
| 784 |
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
}
|
| 788 |
|
| 789 |
-
|
| 790 |
-
|
| 791 |
|
| 792 |
-
|
| 793 |
-
|
| 794 |
|
| 795 |
-
|
|
|
|
|
|
|
| 796 |
|
| 797 |
-
|
| 798 |
-
|
| 799 |
|
| 800 |
-
//
|
| 801 |
-
$
|
| 802 |
|
| 803 |
-
|
| 804 |
-
ai1wm_write( $file_handler, $drop_table );
|
| 805 |
|
| 806 |
// Get create table statement
|
| 807 |
-
|
| 808 |
|
| 809 |
-
|
| 810 |
-
|
| 811 |
|
| 812 |
-
|
| 813 |
-
|
| 814 |
|
| 815 |
-
|
| 816 |
-
|
| 817 |
|
| 818 |
-
|
| 819 |
-
|
| 820 |
|
| 821 |
-
|
| 822 |
-
|
| 823 |
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
}
|
| 827 |
|
| 828 |
-
|
| 829 |
-
|
| 830 |
|
| 831 |
-
|
| 832 |
-
|
| 833 |
|
| 834 |
-
|
| 835 |
-
|
|
|
|
| 836 |
|
| 837 |
-
|
|
|
|
| 838 |
|
| 839 |
-
//
|
| 840 |
-
|
| 841 |
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
foreach ( $primary_keys as $key ) {
|
| 845 |
-
$table_keys[] = sprintf( '`%s`', $key );
|
| 846 |
-
}
|
| 847 |
|
| 848 |
-
|
| 849 |
|
| 850 |
-
// Set
|
| 851 |
-
|
| 852 |
-
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
| 853 |
-
$table_where[] = $clause;
|
| 854 |
-
}
|
| 855 |
|
| 856 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 857 |
|
| 858 |
-
|
| 859 |
-
$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 );
|
| 860 |
|
| 861 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
|
| 863 |
-
|
| 864 |
-
$table_keys = 1;
|
| 865 |
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
| 869 |
-
$table_where[] = $clause;
|
| 870 |
-
}
|
| 871 |
|
| 872 |
-
|
| 873 |
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
}
|
| 877 |
|
| 878 |
-
|
| 879 |
-
|
|
|
|
|
|
|
|
|
|
| 880 |
|
| 881 |
-
|
| 882 |
-
if ( $this->errno() === 1194 ) {
|
| 883 |
|
| 884 |
-
|
| 885 |
-
|
|
|
|
| 886 |
|
| 887 |
// Run SQL query
|
| 888 |
$result = $this->query( $query );
|
| 889 |
-
}
|
| 890 |
|
| 891 |
-
|
| 892 |
-
|
| 893 |
|
| 894 |
-
|
| 895 |
-
|
| 896 |
|
| 897 |
-
//
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
|
|
|
|
|
|
| 901 |
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
|
|
|
| 907 |
}
|
| 908 |
|
| 909 |
-
$items
|
| 910 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
|
| 912 |
-
|
| 913 |
-
|
| 914 |
|
| 915 |
-
|
| 916 |
-
|
| 917 |
|
| 918 |
-
|
| 919 |
-
|
| 920 |
|
| 921 |
-
|
| 922 |
-
|
|
|
|
|
|
|
|
|
|
| 923 |
|
| 924 |
-
|
| 925 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
|
| 927 |
// Write end of transaction
|
| 928 |
-
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES
|
| 929 |
ai1wm_write( $file_handler, "COMMIT;\n" );
|
| 930 |
}
|
| 931 |
-
}
|
| 932 |
-
} else {
|
| 933 |
|
| 934 |
-
|
| 935 |
-
|
| 936 |
-
ai1wm_write( $file_handler, "COMMIT;\n" );
|
| 937 |
-
}
|
| 938 |
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
|
| 942 |
-
// Set current table offset
|
| 943 |
-
$table_offset = 0;
|
| 944 |
-
}
|
| 945 |
|
| 946 |
-
|
| 947 |
-
|
| 948 |
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
|
|
|
| 954 |
}
|
| 955 |
-
}
|
| 956 |
-
}
|
| 957 |
}
|
| 958 |
}
|
| 959 |
|
|
|
|
|
|
|
|
|
|
| 960 |
// Close file handler
|
| 961 |
ai1wm_close( $file_handler );
|
| 962 |
|
|
@@ -975,7 +983,7 @@ abstract class Ai1wm_Database {
|
|
| 975 |
$max_allowed_packet = $this->get_max_allowed_packet();
|
| 976 |
|
| 977 |
// Set file handler
|
| 978 |
-
$file_handler = ai1wm_open( $file_name, '
|
| 979 |
|
| 980 |
// Start time
|
| 981 |
$start = microtime( true );
|
|
@@ -1076,9 +1084,6 @@ abstract class Ai1wm_Database {
|
|
| 1076 |
}
|
| 1077 |
}
|
| 1078 |
|
| 1079 |
-
// Set query offset
|
| 1080 |
-
$query_offset = ftell( $file_handler );
|
| 1081 |
-
|
| 1082 |
// Time elapsed
|
| 1083 |
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
| 1084 |
if ( ! $this->is_atomic_query( $query ) ) {
|
|
@@ -1098,6 +1103,9 @@ abstract class Ai1wm_Database {
|
|
| 1098 |
$this->query( 'COMMIT' );
|
| 1099 |
}
|
| 1100 |
|
|
|
|
|
|
|
|
|
|
| 1101 |
// Close file handler
|
| 1102 |
ai1wm_close( $file_handler );
|
| 1103 |
|
| 717 |
* Export database into a file
|
| 718 |
*
|
| 719 |
* @param string $file_name File name
|
| 720 |
+
* @param integer $query_offset Query offset
|
| 721 |
* @param integer $table_index Table index
|
| 722 |
* @param integer $table_offset Table offset
|
| 723 |
* @param integer $table_rows Table rows
|
| 724 |
* @return boolean
|
| 725 |
*/
|
| 726 |
+
public function export( $file_name, &$query_offset = 0, &$table_index = 0, &$table_offset = 0, &$table_rows = 0 ) {
|
| 727 |
// Set file handler
|
| 728 |
+
$file_handler = ai1wm_open( $file_name, 'cb' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 729 |
|
| 730 |
// Start time
|
| 731 |
$start = microtime( true );
|
| 742 |
// Get views
|
| 743 |
$views = $this->get_views();
|
| 744 |
|
| 745 |
+
// Set file pointer at the query offset
|
| 746 |
+
if ( fseek( $file_handler, $query_offset ) !== -1 ) {
|
| 747 |
|
| 748 |
+
// Write headers
|
| 749 |
+
if ( $query_offset === 0 ) {
|
| 750 |
+
ai1wm_write( $file_handler, $this->get_header() );
|
| 751 |
+
}
|
| 752 |
|
| 753 |
+
// Export tables
|
| 754 |
+
for ( ; $table_index < count( $tables ); ) {
|
| 755 |
|
| 756 |
+
// Get table name
|
| 757 |
+
$table_name = $tables[ $table_index ];
|
| 758 |
|
| 759 |
+
// Replace table name prefixes
|
| 760 |
+
$new_table_name = $this->replace_table_prefixes( $table_name, 0 );
|
| 761 |
|
| 762 |
+
// Loop over tables and views
|
| 763 |
+
if ( in_array( $table_name, $views ) ) {
|
|
|
|
|
|
|
|
|
|
| 764 |
|
| 765 |
// Get create view statement
|
| 766 |
+
if ( $table_offset === 0 ) {
|
| 767 |
|
| 768 |
+
// Write view drop statement
|
| 769 |
+
$drop_view = "\nDROP VIEW IF EXISTS `{$new_table_name}`;\n";
|
| 770 |
|
| 771 |
+
// Write drop view statement
|
| 772 |
+
ai1wm_write( $file_handler, $drop_view );
|
| 773 |
|
| 774 |
+
// Get create view statement
|
| 775 |
+
$create_view = $this->get_create_view( $table_name );
|
| 776 |
|
| 777 |
+
// Replace create view name
|
| 778 |
+
$create_view = $this->replace_view_name( $create_view, $table_name, $new_table_name );
|
| 779 |
|
| 780 |
+
// Replace create view identifiers
|
| 781 |
+
$create_view = $this->replace_view_identifiers( $create_view );
|
|
|
|
| 782 |
|
| 783 |
+
// Replace create view options
|
| 784 |
+
$create_view = $this->replace_view_options( $create_view );
|
| 785 |
|
| 786 |
+
// Write create view statement
|
| 787 |
+
ai1wm_write( $file_handler, $create_view );
|
| 788 |
|
| 789 |
+
// Write end of statement
|
| 790 |
+
ai1wm_write( $file_handler, ";\n\n" );
|
| 791 |
+
}
|
| 792 |
|
| 793 |
+
// Set curent table index
|
| 794 |
+
$table_index++;
|
| 795 |
|
| 796 |
+
// Set current table offset
|
| 797 |
+
$table_offset = 0;
|
| 798 |
|
| 799 |
+
} else {
|
|
|
|
| 800 |
|
| 801 |
// Get create table statement
|
| 802 |
+
if ( $table_offset === 0 ) {
|
| 803 |
|
| 804 |
+
// Write table drop statement
|
| 805 |
+
$drop_table = "\nDROP TABLE IF EXISTS `{$new_table_name}`;\n";
|
| 806 |
|
| 807 |
+
// Write table statement
|
| 808 |
+
ai1wm_write( $file_handler, $drop_table );
|
| 809 |
|
| 810 |
+
// Get create table statement
|
| 811 |
+
$create_table = $this->get_create_table( $table_name );
|
| 812 |
|
| 813 |
+
// Replace create table name
|
| 814 |
+
$create_table = $this->replace_table_name( $create_table, $table_name, $new_table_name );
|
| 815 |
|
| 816 |
+
// Replace create table comments
|
| 817 |
+
$create_table = $this->replace_table_comments( $create_table );
|
| 818 |
|
| 819 |
+
// Replace create table constraints
|
| 820 |
+
$create_table = $this->replace_table_constraints( $create_table );
|
|
|
|
| 821 |
|
| 822 |
+
// Replace create table options
|
| 823 |
+
$create_table = $this->replace_table_options( $create_table );
|
| 824 |
|
| 825 |
+
// Write create table statement
|
| 826 |
+
ai1wm_write( $file_handler, $create_table );
|
| 827 |
|
| 828 |
+
// Write end of statement
|
| 829 |
+
ai1wm_write( $file_handler, ";\n\n" );
|
| 830 |
+
}
|
| 831 |
|
| 832 |
+
// Get primary keys
|
| 833 |
+
$primary_keys = $this->get_primary_keys( $table_name );
|
| 834 |
|
| 835 |
+
// Get table columns
|
| 836 |
+
$table_columns = $this->get_column_types( $table_name );
|
| 837 |
|
| 838 |
+
// Get prefix columns
|
| 839 |
+
$prefix_columns = $this->get_table_prefix_columns( $table_name );
|
|
|
|
|
|
|
|
|
|
| 840 |
|
| 841 |
+
do {
|
| 842 |
|
| 843 |
+
// Set query
|
| 844 |
+
if ( $primary_keys ) {
|
|
|
|
|
|
|
|
|
|
| 845 |
|
| 846 |
+
// Set table keys
|
| 847 |
+
$table_keys = array();
|
| 848 |
+
foreach ( $primary_keys as $key ) {
|
| 849 |
+
$table_keys[] = sprintf( '`%s`', $key );
|
| 850 |
+
}
|
| 851 |
|
| 852 |
+
$table_keys = implode( ', ', $table_keys );
|
|
|
|
| 853 |
|
| 854 |
+
// Set table where clauses
|
| 855 |
+
$table_where = array( 1 );
|
| 856 |
+
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
| 857 |
+
$table_where[] = $clause;
|
| 858 |
+
}
|
| 859 |
|
| 860 |
+
$table_where = implode( ' AND ', $table_where );
|
|
|
|
| 861 |
|
| 862 |
+
// Set query with offset and rows count
|
| 863 |
+
$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 );
|
|
|
|
|
|
|
|
|
|
| 864 |
|
| 865 |
+
} else {
|
| 866 |
|
| 867 |
+
// Set table keys
|
| 868 |
+
$table_keys = 1;
|
|
|
|
| 869 |
|
| 870 |
+
// Set table where clauses
|
| 871 |
+
$table_where = array( 1 );
|
| 872 |
+
foreach ( $this->get_table_where_clauses( $table_name ) as $clause ) {
|
| 873 |
+
$table_where[] = $clause;
|
| 874 |
+
}
|
| 875 |
|
| 876 |
+
$table_where = implode( ' AND ', $table_where );
|
|
|
|
| 877 |
|
| 878 |
+
// Set query with offset and rows count
|
| 879 |
+
$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 );
|
| 880 |
+
}
|
| 881 |
|
| 882 |
// Run SQL query
|
| 883 |
$result = $this->query( $query );
|
|
|
|
| 884 |
|
| 885 |
+
// Repair table data
|
| 886 |
+
if ( $this->errno() === 1194 ) {
|
| 887 |
|
| 888 |
+
// Current table is marked as crashed and should be repaired
|
| 889 |
+
$this->repair_table( $table_name );
|
| 890 |
|
| 891 |
+
// Run SQL query
|
| 892 |
+
$result = $this->query( $query );
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
// Generate insert statements
|
| 896 |
+
if ( $num_rows = $this->num_rows( $result ) ) {
|
| 897 |
|
| 898 |
+
// Loop over table rows
|
| 899 |
+
while ( $row = $this->fetch_assoc( $result ) ) {
|
| 900 |
+
|
| 901 |
+
// Write start transaction
|
| 902 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES === 0 ) {
|
| 903 |
+
ai1wm_write( $file_handler, "START TRANSACTION;\n" );
|
| 904 |
}
|
| 905 |
|
| 906 |
+
$items = array();
|
| 907 |
+
foreach ( $row as $key => $value ) {
|
| 908 |
+
// Replace table prefix columns
|
| 909 |
+
if ( isset( $prefix_columns[ strtolower( $key ) ] ) ) {
|
| 910 |
+
$value = $this->replace_column_prefixes( $value, 0 );
|
| 911 |
+
}
|
| 912 |
|
| 913 |
+
$items[] = $this->prepare_table_values( $value, $table_columns[ strtolower( $key ) ] );
|
| 914 |
+
}
|
| 915 |
|
| 916 |
+
// Set table values
|
| 917 |
+
$table_values = implode( ',', $items );
|
| 918 |
|
| 919 |
+
// Set insert statement
|
| 920 |
+
$table_insert = "INSERT INTO `{$new_table_name}` VALUES ({$table_values});\n";
|
| 921 |
|
| 922 |
+
// Write insert statement
|
| 923 |
+
ai1wm_write( $file_handler, $table_insert );
|
| 924 |
+
|
| 925 |
+
// Set current table offset
|
| 926 |
+
$table_offset++;
|
| 927 |
|
| 928 |
+
// Set current table rows
|
| 929 |
+
$table_rows++;
|
| 930 |
+
|
| 931 |
+
// Write end of transaction
|
| 932 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES === 0 ) {
|
| 933 |
+
ai1wm_write( $file_handler, "COMMIT;\n" );
|
| 934 |
+
}
|
| 935 |
+
}
|
| 936 |
+
} else {
|
| 937 |
|
| 938 |
// Write end of transaction
|
| 939 |
+
if ( $table_offset % AI1WM_MAX_TRANSACTION_QUERIES !== 0 ) {
|
| 940 |
ai1wm_write( $file_handler, "COMMIT;\n" );
|
| 941 |
}
|
|
|
|
|
|
|
| 942 |
|
| 943 |
+
// Set curent table index
|
| 944 |
+
$table_index++;
|
|
|
|
|
|
|
| 945 |
|
| 946 |
+
// Set current table offset
|
| 947 |
+
$table_offset = 0;
|
| 948 |
+
}
|
|
|
|
|
|
|
|
|
|
| 949 |
|
| 950 |
+
// Close result cursor
|
| 951 |
+
$this->free_result( $result );
|
| 952 |
|
| 953 |
+
// Time elapsed
|
| 954 |
+
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
| 955 |
+
if ( ( microtime( true ) - $start ) > $timeout ) {
|
| 956 |
+
$completed = false;
|
| 957 |
+
break 2;
|
| 958 |
+
}
|
| 959 |
}
|
| 960 |
+
} while ( $num_rows > 0 );
|
| 961 |
+
}
|
| 962 |
}
|
| 963 |
}
|
| 964 |
|
| 965 |
+
// Set query offset
|
| 966 |
+
$query_offset = ftell( $file_handler );
|
| 967 |
+
|
| 968 |
// Close file handler
|
| 969 |
ai1wm_close( $file_handler );
|
| 970 |
|
| 983 |
$max_allowed_packet = $this->get_max_allowed_packet();
|
| 984 |
|
| 985 |
// Set file handler
|
| 986 |
+
$file_handler = ai1wm_open( $file_name, 'rb' );
|
| 987 |
|
| 988 |
// Start time
|
| 989 |
$start = microtime( true );
|
| 1084 |
}
|
| 1085 |
}
|
| 1086 |
|
|
|
|
|
|
|
|
|
|
| 1087 |
// Time elapsed
|
| 1088 |
if ( ( $timeout = apply_filters( 'ai1wm_completed_timeout', 10 ) ) ) {
|
| 1089 |
if ( ! $this->is_atomic_query( $query ) ) {
|
| 1103 |
$this->query( 'COMMIT' );
|
| 1104 |
}
|
| 1105 |
|
| 1106 |
+
// Set query offset
|
| 1107 |
+
$query_offset = ftell( $file_handler );
|
| 1108 |
+
|
| 1109 |
// Close file handler
|
| 1110 |
ai1wm_close( $file_handler );
|
| 1111 |
|
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.6
|
| 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,11 @@ 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.32 =
|
| 112 |
**Added**
|
| 113 |
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 5.6
|
| 6 |
Requires PHP: 5.2.17
|
| 7 |
+
Stable tag: 7.33
|
| 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.33 =
|
| 112 |
+
**Added**
|
| 113 |
+
|
| 114 |
+
* Improved database export
|
| 115 |
+
|
| 116 |
= 7.32 =
|
| 117 |
**Added**
|
| 118 |
|
