Changeset 3485190
- Timestamp:
- 03/18/2026 12:13:37 AM (9 days ago)
- Location:
- prime-mover/trunk
- Files:
-
- 2 deleted
- 21 edited
-
PrimeMoverFactory.php (modified) (5 diffs)
-
build/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php (modified) (1 diff)
-
changelog.txt (modified) (1 diff)
-
classes/PrimeMoverErrorHandlers.php (modified) (1 diff)
-
classes/PrimeMoverExporter.php (modified) (4 diffs)
-
classes/PrimeMoverImporter.php (modified) (3 diffs)
-
classes/PrimeMoverSystemChecks.php (modified) (2 diffs)
-
classes/PrimeMoverSystemInitialization.php (modified) (3 diffs)
-
cli/PrimeMoverCLIArchive.php (modified) (3 diffs)
-
cli/PrimeMoverCLIShellArchiver.php (deleted)
-
compatibility/PrimeMoverFreemiusCompat.php (modified) (1 diff)
-
engines/prime-mover-panel/prime-mover-panel.php (modified) (1 diff)
-
engines/prime-mover-panel/vendor/composer/installed.php (modified) (2 diffs)
-
global/PrimeMoverGlobalConstants.php (modified) (1 diff)
-
global/PrimeMoverGlobalFunctions.php (modified) (1 diff)
-
prime-mover.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
scripts/prime-mover-shell-archiver.php (deleted)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/autoload_classmap.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (2 diffs)
-
vendor/composer/autoload_static.php (modified) (3 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
prime-mover/trunk/PrimeMoverFactory.php
r3400102 r3485190 42 42 use Codexonics\PrimeMoverFramework\streams\PrimeMoverResumableDownloadStream; 43 43 use Codexonics\PrimeMoverFramework\streams\PrimeMoverIterators; 44 use Codexonics\PrimeMoverFramework\cli\PrimeMoverCLIShellArchiver;45 44 use Codexonics\PrimeMoverFramework\cli\PrimeMoverCLIArchive; 46 45 use Codexonics\PrimeMoverFramework\menus\PrimeMoverBackupMenus; … … 76 75 */ 77 76 class PrimeMoverFactory 78 { 79 80 /** 81 * Mode of execution, CLI or normal 82 * @var boolean 83 */ 84 private $cli = false; 85 86 /** 87 * Parameters passed, $argv for CLI 88 * @var array 89 */ 90 private $parameters = []; 91 92 /** 93 * Constructor 94 * @param boolean $cli 95 * @param array $parameters 96 */ 97 public function __construct($cli = false, $parameters = []) 98 { 99 $this->cli = $cli; 100 $this->parameters = $parameters; 77 { 78 /** 79 * Initialize hook 80 */ 81 public function initHook() 82 { 83 add_action('init', [$this, 'composeObjects'], 0); 101 84 } 102 103 /**104 * Get Cli105 * @return boolean106 */107 public function getCli()108 {109 return $this->cli;110 }111 112 /**113 * Get parameters114 * @return array115 */116 public function getParameters()117 {118 return $this->parameters;119 }120 121 /**122 * Initialize hook123 */124 public function initHook()125 {126 add_action('init', [$this, 'composeObjects'], 0);127 add_filter( 'determine_current_user', [$this, 'setUser'], 10, 1 );128 }129 85 130 86 /** … … 146 102 147 103 $this->removePluginManagerOnUninstall(); 148 }149 150 /**151 * Set user if needed152 * @param mixed $user153 * @return mixed154 */155 public function setUser($user)156 {157 if ($this->getCli() && defined('PRIME_MOVER_COPY_MEDIA_SHELL_USER') && defined('PRIME_MOVER_DOING_SHELL_ARCHIVE') && PRIME_MOVER_DOING_SHELL_ARCHIVE) {158 return PRIME_MOVER_COPY_MEDIA_SHELL_USER;159 }160 return $user;161 104 } 162 105 … … 306 249 307 250 $db_utilities = new PrimeMoverDatabaseUtilities($prime_mover, $utilities); 308 $db_utilities->initHooks(); 309 310 if ($this->getCli()) { 311 $parameters = $this->getParameters(); 312 $cli = new PrimeMoverCLIShellArchiver($prime_mover, $utilities, $parameters); 313 $cli->initHooks(); 314 } 251 $db_utilities->initHooks(); 315 252 316 253 $backup_menu = new PrimeMoverBackupMenus($prime_mover, $utilities); … … 591 528 /** 592 529 * Instantiate 593 * @var \Codexonics\PrimeMoverFactory $loaded_instance594 530 */ 595 $cli = false; 596 $parameters = []; 597 598 if ("cli" === php_sapi_name()) { 599 $cli = true; 600 601 /** @var mixed $argv Command Line arguments*/ 602 global $argv; 603 $parameters = $argv; 604 } 605 606 $loaded_instance = new PrimeMoverFactory($cli, $parameters); 531 $loaded_instance = new PrimeMoverFactory(); 607 532 $loaded_instance->initHook(); 608 533 $loaded_instance->loadActivationHook(); -
prime-mover/trunk/build/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php
r3176508 r3485190 152 152 $this->pass = $pass; 153 153 $this->parseDsn($dsn); 154 $is_dbtype_mysql = \false; 155 if ("mysql" === $this->dbType) { 156 $is_dbtype_mysql = \true; 157 } 158 $buffered_query = ''; 159 // PHP 8.5 COMPATIBILITY - USE NEW CONSTANT IF SET 160 if ($is_dbtype_mysql && \defined('Pdo\\Mysql::ATTR_USE_BUFFERED_QUERY')) { 161 $buffered_query = Pdo\Mysql::ATTR_USE_BUFFERED_QUERY; 162 } 163 //BACKWARD COMPATBILITY TO PREVIOUS PHP VERSIONS - FALLBACK TO ORIGINAL IF NOT YET SET 164 if ($is_dbtype_mysql && empty($buffered_query)) { 165 $buffered_query = PDO::MYSQL_ATTR_USE_BUFFERED_QUERY; 166 } 154 167 // This drops MYSQL dependency, only use the constant if it's defined. 155 if ( "mysql" === $this->dbType) {156 $pdoSettingsDefault[ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = \false;168 if ($is_dbtype_mysql && $buffered_query) { 169 $pdoSettingsDefault[$buffered_query] = \false; 157 170 } 158 171 $this->pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings); -
prime-mover/trunk/changelog.txt
r3455709 r3485190 2 2 3 3 **This is a list detailing changes for all Prime Mover releases.** 4 5 = 2.1.0 = 6 7 * Fixed: Deprecated notices in the PHP 8.4 latest version. 8 * Fixed: Outdated libraries to work in PHP 8.4. 9 * Fixed: Updated all third-party libraries to work from PHP 5.6 to PHP 8.4. 10 * Fixed: Updated the Freemius SDK to version 2.12.2. 4 11 5 12 = 2.0.9 = -
prime-mover/trunk/classes/PrimeMoverErrorHandlers.php
r3400102 r3485190 351 351 return $error_output; 352 352 } 353 /** 354 * @var mixed $output phpinfo CLI output 355 */ 356 if ('cli' === php_sapi_name()) { 357 exec("php -i", $output); 358 $phpinfoarray = $output; 359 } else { 360 $phpinfoarray = $this->getShutDownUtilities()->phpinfo2array(); 361 } 362 353 354 $phpinfoarray = $this->getShutDownUtilities()->phpinfo2array(); 363 355 $error_output = array_merge($error_output, $phpinfoarray); 364 356 -
prime-mover/trunk/classes/PrimeMoverExporter.php
r3455709 r3485190 1001 1001 1002 1002 $this->getSystemFunctions()->temporarilyIncreaseMemoryLimits(); 1003 $dump_result = $this->executeDumpUsingPHP($filter_export_data, $target_path, $clean_tables, $ret, $start_time, $blogid_to_export); 1004 1005 } else { 1006 do_action('prime_mover_log_processed_events', 'Starting MySQLdump using native shell command.', $blogid_to_export, 'export', $current_func, $this); 1007 $this->getSystemFunctions()->temporarilyIncreaseMemoryLimits(); 1008 $dump_result = $this->doMySqlDumpUsingShell($clean_tables, $filter_export_data, $target_path, $blogid_to_export, $ret, $start_time); 1009 } 1003 $dump_result = $this->executeDumpUsingPHP($filter_export_data, $target_path, $clean_tables, $ret, $start_time, $blogid_to_export); 1004 } 1010 1005 1011 1006 return $dump_result; … … 1042 1037 1043 1038 /** 1044 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverExporter::itChecksWhetherToUseMySQLDumpPHP()1045 * Maybe use MySQL Dump PHP if shell isn't supported1046 * @param array $ret1047 * @return boolean1048 * @deprecated1049 */1050 protected function maybeUseMySQLDumpPhp($ret = [])1051 {1052 $use_mysqldump_php = true;1053 if ( ! empty($ret['force_dbdump_in_php'] ) ) {1054 return $use_mysqldump_php;1055 }1056 1057 $shell_support = $this->getCliArchiver()->maybeArchiveMediaByShell();1058 $mysqldump_path = $this->getSystemChecks()->getMySqlDumpPath();1059 1060 if ($mysqldump_path && is_array($shell_support)) {1061 $use_mysqldump_php = false;1062 }1063 1064 return $use_mysqldump_php;1065 }1066 1067 /**1068 1039 * Checks if dump is in progress 1069 1040 * @param array $ret … … 1079 1050 $this->getSystemInitialization()->setSlowProcess(); 1080 1051 return $dump_in_progress; 1081 }1082 1083 /**1084 * MySQL dump using shell1085 * @param array $tables_to_dumped_shell1086 * @param boolean $filter_export_data1087 * @param string $target_path1088 * @param number $blogid_to_export1089 * @param array $ret1090 * @param number $db_dump_start1091 * @return boolean1092 */1093 private function doMySqlDumpUsingShell($tables_to_dumped_shell = [], $filter_export_data = false, $target_path = '', $blogid_to_export = 0, $ret = [], $db_dump_start = 0)1094 {1095 if ( ! empty($ret['shell_db_dump_clean_tables']) ) {1096 1097 $tables_to_dumped_shell = $ret['shell_db_dump_clean_tables'];1098 unset($ret['shell_db_dump_clean_tables']);1099 }1100 1101 $original_tables_count = count($tables_to_dumped_shell);1102 if ( ! empty($ret['shell_db_dump_original_table_counts']) ) {1103 1104 $original_tables_count = $ret['shell_db_dump_original_table_counts'];1105 unset($ret['shell_db_dump_original_table_counts']);1106 }1107 1108 foreach ($tables_to_dumped_shell as $key => $table_shell_dumped) {1109 $limit = 500000;1110 1111 $offset = 0;1112 if ( ! empty($ret['shell_db_dump_index_to_resume']) ) {1113 $offset = $ret['shell_db_dump_index_to_resume'];1114 unset($ret['shell_db_dump_index_to_resume']);1115 }1116 1117 $create_table = true;1118 if (isset($ret['shell_db_dump_create_tables'])) {1119 $create_table = $ret['shell_db_dump_create_tables'];1120 unset($ret['shell_db_dump_create_tables']);1121 }1122 1123 while ($shell_dump_res = $this->executeDumpUsingShellFunctions($filter_export_data, $target_path, $blogid_to_export, $table_shell_dumped, $offset, $ret, $limit,1124 $original_tables_count, $tables_to_dumped_shell, $create_table)) {1125 if ( ! empty($shell_dump_res['error']) ) {1126 $ret['error'] = $shell_dump_res['error'];1127 break;1128 }1129 $offset = $limit + $offset;1130 $create_table = false;1131 $retry_timeout = apply_filters('prime_mover_retry_timeout_seconds', PRIME_MOVER_RETRY_TIMEOUT_SECONDS, 'doMySqlDumpUsingShell');1132 if (microtime(true) - $db_dump_start > $retry_timeout) {1133 1134 do_action('prime_mover_log_processed_events', "$retry_timeout seconds time out hits while dumping database. Offset to resume: $offset, Table to resume: $table_shell_dumped", $blogid_to_export, 'export', __FUNCTION__, $this);1135 1136 $count_ongoing_tables_for_dumping = count($tables_to_dumped_shell);1137 $completed_dumped = $original_tables_count - $count_ongoing_tables_for_dumping;1138 $percent = round(($completed_dumped / $original_tables_count) * 100, 0) . '%';1139 1140 $ret['dump_percent_progress'] = $percent;1141 $ret['shell_db_dump_clean_tables'] = $tables_to_dumped_shell;1142 $ret['shell_db_dump_index_to_resume'] = $offset;1143 $ret['shell_db_dump_original_table_counts'] = $original_tables_count;1144 $ret['shell_db_dump_create_tables'] = $create_table;1145 $ret = $this->getSystemInitialization()->maybeAutomaticBackupTimeout($ret);1146 1147 return $ret;1148 }1149 }1150 if ( ! empty($ret['error']) ) {1151 return $ret;1152 }1153 unset($tables_to_dumped_shell[$key]);1154 }1155 1156 if (isset($ret['shell_db_dump_index_to_resume'])) {1157 unset($ret['shell_db_dump_index_to_resume']);1158 }1159 return $ret;1160 }1161 1162 /**1163 * Execute dump in shell if supported1164 * @param string $command1165 * @param boolean $filter_export_data1166 * @param string $target_path1167 * @return array1168 *1169 */1170 private function executeDumpUsingShellFunctions($filter_export_data = false, $target_path = '', $blogid_to_export = 0, $table_shell_dumped = [], $offset = 0,1171 $ret = [], $limit = 0, $original_tables_count = 0, $clean_tables = [], $create_table = true)1172 {1173 $delete_sql_if_exist = false;1174 $clean_tables_count = count($clean_tables);1175 if ($clean_tables_count === $original_tables_count && 0 === $offset) {1176 $delete_sql_if_exist = true;1177 }1178 $command = $this->generateMySQLDumpShellCommand($ret, $blogid_to_export, [$table_shell_dumped], $limit, $offset, $create_table);1179 $dump_ret = [];1180 if ( ! $command || ! $target_path ) {1181 $dump_ret['error'] = esc_html__('Undefined execute dump in shell parameters.', 'prime-mover');1182 return $dump_ret;1183 }1184 if (is_array($command) && isset($command['error'])) {1185 $dump_ret['error'] = $command['error'];1186 return $dump_ret;1187 }1188 if (! $this->getSystemAuthorization()->isUserAuthorized()) {1189 $dump_ret['error'] = esc_html__('Unauthorized dump.', 'prime-mover');1190 return $dump_ret;1191 }1192 $handle = popen("($command)","r");1193 if (false === $handle) {1194 $dump_ret['error'] = esc_html__('Error in MySQLdump shell using popen.', 'prime-mover');1195 return $dump_ret;1196 }1197 1198 if ($delete_sql_if_exist) {1199 $this->getSystemFunctions()->primeMoverDoDelete($target_path);1200 }1201 1202 $bytes_written = 0;1203 while(!feof($handle)){1204 $line = fgets($handle);1205 1206 if (false === $line) {1207 break;1208 }1209 if ($filter_export_data) {1210 $line = apply_filters('prime_mover_filter_export_db_data', $line);1211 $line = $line . PHP_EOL;1212 }1213 $bytes_written += file_put_contents($target_path, $line, FILE_APPEND);1214 }1215 1216 pclose($handle);1217 return $bytes_written;1218 1052 } 1219 1053 … … 1390 1224 1391 1225 /** 1392 * Generate MySQL dump shell command1393 * @param array $ret1394 * @param number $blogid_to_export1395 * @param array $clean_tables1396 * @return mixed1397 *1398 */1399 private function generateMySQLDumpShellCommand($ret = [], $blogid_to_export = 0, $clean_tables = [], $limit = 100, $offset = 0, $create_table = true)1400 {1401 $no_password = false;1402 if (empty(DB_PASSWORD)) {1403 $no_password = true;1404 }1405 1406 $db_username = escapeshellarg(DB_USER);1407 $db_password = escapeshellarg(DB_PASSWORD);1408 $db_name = escapeshellarg(DB_NAME);1409 1410 if (empty($clean_tables)) {1411 $ret['error'] = esc_html__('Unable to dump database, please check that your database is not empty or these tables exists.', 'prime-mover');1412 return $ret;1413 }1414 $tables = implode(" ", $clean_tables);1415 $mysqldump_path = $this->getSystemChecks()->getMySqlDumpPath();1416 if (! $mysqldump_path) {1417 $ret['error'] = esc_html__('Unable to get correct MySQLdump command.', 'prime-mover');1418 return $ret;1419 }1420 $mysqldump_path = escapeshellarg($mysqldump_path);1421 $password_phrase = ' ';1422 if (false === $no_password) {1423 $password_phrase = ' -p'. $db_password;1424 $password_phrase = apply_filters('prime_mover_passwordless_dump', $password_phrase);1425 }1426 1427 $db_host = $this->getSystemFunctions()->parsedBHostForPDO();1428 if ( ! $db_host ) {1429 $ret['error'] = esc_html__('Unable to parse DB_HOST for MySQL command execution.', 'prime-mover');1430 return $ret;1431 }1432 if (empty($db_host['host'])) {1433 $ret['error'] = esc_html__('Error, no known DB host to connect.', 'prime-mover');1434 return $ret;1435 }1436 1437 $db_hostname = $db_host['host'];1438 $db_hostname = escapeshellarg($db_hostname);1439 1440 $port = '';1441 if ( ! empty($db_host['port'] ) && $db_host['port'] > 0) {1442 $port = (int)$db_host['port'];1443 $port = escapeshellarg($port);1444 }1445 1446 $socket = '';1447 if ( ! empty($db_host['socket'] )) {1448 $socket = $db_host['socket'];1449 }1450 1451 $port_phrase = ' ';1452 if ($port) {1453 $port_phrase = ' -P '. $port;1454 }1455 1456 $socket_phrase = ' ';1457 if ($socket) {1458 $socket_phrase = ' -S '. $socket;1459 }1460 1461 $limit = (int)$limit;1462 $offset = (int)$offset;1463 1464 $limit_phrase = "--where=1 limit $offset, $limit";1465 $limit_phrase = escapeshellarg($limit_phrase);1466 1467 $create_info_phrase = '';1468 1469 $compact_phrase = '';1470 if ( ! $create_table) {1471 $create_info_phrase = "--no-create-info";1472 $compact_phrase = "--compact";1473 }1474 1475 $dump_command = $mysqldump_path . ' '.1476 $password_phrase .1477 ' -u' . $db_username .1478 ' -h'. $db_hostname . ' ' .1479 $port_phrase . ' ' .1480 $socket_phrase . ' ' .1481 $limit_phrase . ' ' .1482 $create_info_phrase . ' ' .1483 $compact_phrase . ' ' .1484 $db_name . ' ' .1485 $tables;1486 1487 return $dump_command;1488 }1489 1490 /**1491 1226 * Count all table rows 1492 1227 * @param array $tables -
prime-mover/trunk/classes/PrimeMoverImporter.php
r3455709 r3485190 602 602 do_action('prime_mover_log_processed_events', "Extract main package..start", $blogid_to_import, 'import', $process_methods['current'], $this); 603 603 604 $copymediabyshell = $this->getCliArchiver()->maybeArchiveMediaByShell();605 604 $extracting_tar = false; 606 605 if (!empty($ret['file']) && $wp_filesystem->exists($ret['file']) && $this->getSystemFunctions()->hasTarExtension($ret['file'])) { … … 609 608 $ret['is_extracting_tar'] = $extracting_tar; 610 609 $shell_progress_key = 'unzipping_main_directory_started'; 611 $error_log_path = $this->getSystemInitialization()->getTroubleShootingLogPath('migration'); 612 613 if ( ! isset($ret[$shell_progress_key])) { 614 $media_tmp_file = $this->createTmpShellFile($extracting_tar); 615 } else { 616 $media_tmp_file = $ret['media_tmp_file']; 617 } 618 619 $task = esc_html__('Processing', 'prime-mover'); 610 620 611 if ( ! isset($ret['file'] ) || ! $wp_filesystem->exists($ret['file'])) { 621 612 if (! isset($ret[$shell_progress_key]) && !$extracting_tar) { … … 649 640 } 650 641 651 $this->getSystemInitialization()->setTemporaryImportPackagePath($unzipped_directory); 652 653 if (is_array($copymediabyshell) && !$extracting_tar) { 654 655 return $this->getCliArchiver()->doShellArchivingTasks($copymediabyshell, $ret, $shell_progress_key, $blogid_to_import, false, '', 'extraction', '', 656 $error_log_path, $media_tmp_file, $process_methods, false, [], $task, 'import'); 657 658 } elseif (!$extracting_tar) { 642 $this->getSystemInitialization()->setTemporaryImportPackagePath($unzipped_directory); 643 if (!$extracting_tar) { 659 644 if (empty($ret['media_zip_last_index'])) { 660 645 $ret['media_zip_last_index'] = 0; -
prime-mover/trunk/classes/PrimeMoverSystemChecks.php
r3455709 r3485190 947 947 return $actions; 948 948 } 949 950 /**951 * Analyze the most correct MySQL dump path based on the system this plugin is running.952 * Inspired by https://wordpress.org/plugins/duplicator/953 * @return boolean|string|954 * @compatible 5.6955 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itGetsMySQLDumpPath()956 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itReturnsFalseIfNoSystemForMySQLDump()957 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itReturnsNullIfNotAuthorizedToDump()958 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itReturnsFalseWhenNoMySQLDumpHandler()959 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itGetsMySQLDumpPathInWindows()960 * @tested PrimeMoverFramework\Tests\TestMigrationSystemChecks::itReturnsFalseWhenNoMySQLDumpHandlerInWindows()961 */962 public function getMySqlDumpPath()963 {964 if (! $this->getSystemAuthorization()->isUserAuthorized()) {965 return;966 }967 //Is system() possible968 if (! $this->hasSystem()) {969 return false;970 }971 $is_windows = false;972 973 if ($this->isWindows()) {974 $is_windows = true;975 976 }977 $paths = [];978 979 /**980 * Using MySQL environment variable(this wont go wrong)981 */982 $binary_executable = $this->getSystemCheckUtilities()->getMySQLBaseDirExecutablePath('mysqldump', $is_windows);983 if ($binary_executable && ! in_array($binary_executable, $paths)) {984 $paths[] = $binary_executable;985 }986 987 // Find the one which works988 foreach ($paths as $path) {989 if ($this->isExecutable($path)) {990 return $path;991 }992 }993 994 return false;995 }996 949 997 950 /** … … 1003 956 return @is_executable($path); 1004 957 } 1005 1006 /**1007 * Can system() be called on this server1008 * Modified from Snap Creek | https://wordpress.org/plugins/duplicator/1009 * @return bool Returns true if system() can be called on server1010 * @compatible 5.61011 *1012 */1013 public function hasSystem()1014 {1015 if (! $this->getSystemAuthorization()->isUserAuthorized()) {1016 return;1017 }1018 $cmds = $this->getSystemInitialization()->getCoreSystemFunctions();1019 if (array_intersect($cmds, array_map('trim', explode(',', @ini_get('disable_functions'))))) {1020 return false;1021 }1022 1023 if (extension_loaded('suhosin')) {1024 $suhosin_ini = @ini_get("suhosin.executor.func.blacklist");1025 if (array_intersect($cmds, array_map('trim', explode(',', $suhosin_ini)))) {1026 return false;1027 }1028 }1029 1030 if (! @shell_exec('echo multisite migration')) {1031 return false;1032 }1033 1034 return true;1035 }1036 958 1037 959 /** -
prime-mover/trunk/classes/PrimeMoverSystemInitialization.php
r3455709 r3485190 91 91 private $is_legacy; 92 92 93 /** @var array coresystem_functions */94 private $coresystem_functions;95 96 93 /** @var string base backup directory */ 97 94 private $basebackupdir; … … 307 304 $this->export_zip_path = ''; 308 305 $this->site_specific_export_folder_created = ''; 309 $this->is_legacy = false; 310 $this->coresystem_functions = ['escapeshellarg', 'escapeshellcmd', 'shell_exec', 'extension_loaded', 'popen', 'exec']; 306 $this->is_legacy = false; 311 307 $this->download_url = ''; 312 308 … … 1360 1356 return $this->download_url; 1361 1357 } 1362 1363 /** 1364 * Gets core system functions required 1365 * @return array 1366 * @compatible 5.6 1367 * @tested Codexonics\PrimeMoverFramework\Tests\TestMigrationSystemInitialization::itGetsCoreSystemFunctions() 1368 */ 1369 public function getCoreSystemFunctions() 1370 { 1371 return $this->coresystem_functions; 1372 } 1373 1358 1374 1359 /** 1375 1360 * Get System authorization -
prime-mover/trunk/cli/PrimeMoverCLIArchive.php
r3455709 r3485190 14 14 use Codexonics\PrimeMoverFramework\classes\PrimeMoverSystemChecks; 15 15 use Codexonics\PrimeMoverFramework\classes\PrimeMoverProgressHandlers; 16 17 /**18 * ZIP ARCHIVER CLASS FOR COMMAND LINE19 * @since 1.0.720 */21 16 22 17 if (! defined('ABSPATH')) { … … 41 36 } 42 37 43 /**38 /** 44 39 * Get shutdown utilities 45 40 * @return \Codexonics\PrimeMoverFramework\utilities\PrimeMoverShutdownUtilities … … 93 88 return $this->progress_handlers; 94 89 } 95 90 96 91 /** 97 * Generate Media archiving arguments 98 * @param boolean $encrypt_media 99 * @param string $media_source_path 100 * @param string $zippath 101 * @param array $exclusion_rules 102 * @param array $blogid_to_export 103 * @param string $error_log_path 104 * @param boolean $delete_source 105 * @param string $mode 106 * @param string $action 107 * @return array 108 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itGenerateMediaArgumentsForShell() 109 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotGenerateMediaArgumentsForShellIfUnauthorized() 110 */ 111 public function generateMediaArchivingArgumentsForShell($encrypt_media = false, $media_source_path = '', $zippath = '', $exclusion_rules = [], 112 $blogid_to_export = [], $error_log_path = '', $delete_source = false, $mode = '', $action = 'export') 113 { 114 $aux_data = []; 115 if (! $this->getSystemAuthorization()->isUserAuthorized()) { 116 return $aux_data; 117 } 118 $encrypt_files = 'plain'; 119 if ($encrypt_media) { 120 $encrypt_files = 'encrypt'; 121 } 122 $export_id = $this->getSystemInitialization()->getExportId(); 123 $import_id = $this->getSystemInitialization()->getImportId(); 124 $aux_data['enable_encryption'] = $encrypt_files; 125 $aux_data['source'] = $media_source_path; 126 $aux_data['zip_path'] = $zippath; 127 $aux_data['exclusion_rules'] = $exclusion_rules; 128 $aux_data['blog_id'] = $blogid_to_export; 129 $aux_data['export_id'] = $export_id; 130 $aux_data['import_id'] = $import_id; 131 $aux_data['ip'] = $this->getSystemInitialization()->getUserIp(); 132 $aux_data['browser'] = $this->getSystemInitialization()->getUserAgent(); 133 $aux_data['error_log_path'] = $error_log_path; 134 $aux_data['action'] = $action; 135 136 if ($delete_source) { 137 $this->getSystemFunctions()->primeMoverDoDelete($zippath); 138 } 139 140 $aux_data = apply_filters('prime_mover_filter_shell_aux_data', $aux_data, $mode); 141 return $aux_data; 142 } 143 144 /** 145 * Execute shell archiving tasks 146 * @param array $ret 147 * @param array $copymediabyshell 148 * @param array $aux_data 149 * @param string $media_tmp_file 150 * @param string $shell_progress_key 151 * @param string $mode 152 * @return array 153 */ 154 public function executeCopyMediaShellCommand($ret = [], $copymediabyshell = [], $aux_data = [], $media_tmp_file = '', $shell_progress_key = '', $mode = 'archivemedia') 155 { 156 if (! $this->getSystemAuthorization()->isUserAuthorized()) { 157 return $ret; 158 } 159 if ( ! is_array($ret) || empty($ret) ) { 160 return $ret; 161 } 162 if ( ! is_array($copymediabyshell) || empty($copymediabyshell) ) { 163 return $ret; 164 } 165 if ( ! is_array($aux_data) || empty($aux_data) ) { 166 return $ret; 167 } 168 if (empty($copymediabyshell ['executable']) || empty($copymediabyshell ['core_load_path'])) { 169 return $ret; 170 } 171 $php_executable = $copymediabyshell ['executable']; 172 $core_load_path = $copymediabyshell ['core_load_path']; 173 $error_log_encoded = base64_encode($aux_data['error_log_path']); 174 $error_log = escapeshellarg($error_log_encoded); 175 176 $ret['shell_progress_key'] = $shell_progress_key; 177 if ( ! empty($aux_data['action']) && ! empty($aux_data[$aux_data['action'] . '_id'])) { 178 $ret['process_id'] = $aux_data[$aux_data['action'] . '_id']; 179 } 180 $ret['cli_start_time'] = microtime(true); 181 $ret_tmp = $ret; 182 $aux_data['media_tmp_file'] = $media_tmp_file; 183 $aux_data['shell_progress_key'] = $shell_progress_key; 184 185 $data = []; 186 $data['ret'] = $ret_tmp; 187 $data['aux'] = $aux_data; 188 $data['mode'] = $mode; 189 190 $data_encoded = base64_encode(json_encode($data)); 191 $raw_data = escapeshellarg($data_encoded); 192 193 $loader = []; 194 $loader['loader'] = $core_load_path; 195 $loader['user_id'] = $this->getSystemInitialization()->getCurrentUserId(); 196 197 $loader['ip'] = $aux_data['ip']; 198 $loader['user_agent'] = $aux_data['browser']; 199 $loader['http_host'] = $this->getSystemInitialization()->getHttpHost(); 200 $loader['request_method'] = $this->getSystemInitialization()->getRequestMethod(); 201 $loader['shell_tmp_file'] = $media_tmp_file; 202 $loader['shell_process_mode'] = $mode; 203 204 $loader_encoded = base64_encode(json_encode($loader)); 205 $loader_data = escapeshellarg($loader_encoded); 206 207 $script = PRIME_MOVER_COPYMEDIA_SCRIPT; 208 $hash_file = $this->getSystemFunctions()->sha256File($media_tmp_file); 209 210 $message = $loader_encoded . $data_encoded . $hash_file . $error_log_encoded; 211 212 $auth_key = $this->getSystemInitialization()->getAuthKey(); 213 $exporter_auth = escapeshellarg(base64_encode(hash_hmac('sha256', $message, $auth_key))); 214 $file_auth = escapeshellarg(base64_encode($media_tmp_file)); 215 $blog_id = $aux_data['blog_id']; 216 217 if ( ! $this->validateExecCall($php_executable, $script, $blog_id)) { 218 return $ret; 219 } 220 221 $this->logShellEvents($shell_progress_key, $blog_id, $data, $loader, $php_executable, $script, $error_log, $loader_data, $raw_data, $exporter_auth, $file_auth); 222 $cli_opcache = $this->enableOpCacheForCli(); 223 $opcache = ''; 224 if ($cli_opcache) { 225 $opcache = '-d opcache.enable_cli=1'; 226 } 227 $process_id = exec("$php_executable $opcache $script $error_log $loader_data $raw_data $exporter_auth $file_auth > /dev/null & echo $!"); 228 229 $ret[$shell_progress_key] = true; 230 $ret['shell_process_id'] = $process_id; 231 $ret['media_tmp_file'] = $media_tmp_file; 232 233 return $ret; 234 } 235 236 /** 237 * Enable opcache for CLI processes if supported 92 * Checks if we need to process using shell functions. These are no longer supported - always return FALSE. 238 93 * @return boolean 239 */240 private function enableOpCacheForCli()241 {242 $result = [];243 if (function_exists('opcache_get_status')) {244 $result = opcache_get_status();245 }246 return (isset($result['opcache_enabled']) && true === $result['opcache_enabled']);247 }248 249 /**250 * Log shell events251 */252 private function logShellEvents($shell_progress_key, $blog_id, $data, $loader, $php_executable, $script, $error_log, $loader_data, $raw_data, $exporter_auth, $file_auth)253 {254 do_action('prime_mover_log_processed_events', "Processing $shell_progress_key action in SHELL with the following parameters: ", $blog_id, 'export', 'executeCopyMediaShellCommand', $this);255 do_action('prime_mover_log_processed_events', "Data array: ", $blog_id, 'export', 'executeCopyMediaShellCommand', $this);256 do_action('prime_mover_log_processed_events', $data, $blog_id, 'export', 'executeCopyMediaShellCommand', $this);257 do_action('prime_mover_log_processed_events', "Loader array: ", $blog_id, 'export', 'executeCopyMediaShellCommand', $this);258 do_action('prime_mover_log_processed_events', $loader, $blog_id, 'export', 'executeCopyMediaShellCommand', $this);259 do_action('prime_mover_log_processed_events', "Command: ", $blog_id, 'export', 'executeCopyMediaShellCommand', $this);260 do_action('prime_mover_log_processed_events', "$php_executable $script $error_log $loader_data $raw_data $exporter_auth $file_auth > /dev/null & echo $!", $blog_id, 'export', 'executeCopyMediaShellCommand', $this);261 }262 263 /**264 * Validate exec caller265 * @param string $given_executable266 * @param string $given_script267 * @param number $blog_id268 * @return boolean269 */270 private function validateExecCall($given_executable = '', $given_script = '', $blog_id = 0)271 {272 if ( ! $given_executable || ! $given_script ) {273 return false;274 }275 276 $script = realpath($given_script);277 if ( ! $this->getSystemFunctions()->fileIsInsideGivenDirectory($given_script, PRIME_MOVER_PLUGIN_CORE_PATH)) {278 do_action('prime_mover_log_processed_events', "ERROR: Exec Files inside given directory fails.", $blog_id, 'export', 'validateExecCall', $this);279 return false;280 }281 if (basename($script) !== PRIME_MOVER_SHELL_ARCHIVER_FILENAME) {282 do_action('prime_mover_log_processed_events', "ERROR: Exec Shell archiver filename fails.", $blog_id, 'export', 'validateExecCall', $this);283 return false;284 }285 $php_executable = $this->getPhpExecutable();286 if ($given_executable !== $php_executable) {287 do_action('prime_mover_log_processed_events', "ERROR: Exec PHP executable fails.", $blog_id, 'export', 'validateExecCall', $this);288 return false;289 }290 291 return true;292 }293 294 /**295 * Checks if shell process is running296 * Linux only297 * @param number $process_id298 * @return boolean299 */300 private function processIsRunning($process_id = 0)301 {302 if ( ! $process_id ) {303 return false;304 }305 $process_id = escapeshellarg($process_id);306 $command = 'ps -p '. $process_id;307 308 /**309 * @var mixed $op output variable310 */311 312 exec($command,$op);313 if (!isset($op[1])) {314 return false;315 } else {316 return true;317 }318 }319 320 /**321 * Returns TRUE if shell archiver is running during export322 * @param array $ret323 * @param array $copymediabyshell324 * @param string $media_tmp_file325 * @param string $shell_progress_key326 * @param number $blogid_to_export327 * @return boolean328 */329 public function shellMediaArchivingProcessRunning($ret = [], $copymediabyshell = [], $media_tmp_file = '', $shell_progress_key = '', $blogid_to_export = 0)330 {331 if ( ! is_array($copymediabyshell) || ! isset( $ret[$shell_progress_key] ) || ! $media_tmp_file || ! $shell_progress_key) {332 $this->logProcessingErrorParameters($ret = [], $blogid_to_export = 0, $copymediabyshell = [], $shell_progress_key = '', $media_tmp_file = '');333 return false;334 }335 336 $process_id = '';337 if ( ! empty($ret['shell_process_id']) ) {338 $process_id = $ret['shell_process_id'];339 }340 341 $running_process = false;342 if ($process_id) {343 $running_process = $this->processIsRunning($process_id);344 }345 346 do_action('prime_mover_log_processed_events', "Process ID: $process_id to be checked whether its running or stopped.", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);347 if ($running_process) {348 do_action('prime_mover_log_processed_events', "Shell process confirmed to be still running. ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);349 } else {350 do_action('prime_mover_log_processed_events', "Shell process NOT anymore running.", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);351 }352 353 $tmp_file_exist = false;354 if ($this->getSystemFunctions()->nonCachedFileExists($media_tmp_file)) {355 do_action('prime_mover_log_processed_events', "Tmp file STILL EXIST, so its running.", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);356 $tmp_file_exist = true;357 } else {358 do_action('prime_mover_log_processed_events', "Tmp file does NOT anymore exist, looks deleted or stopped..", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);359 }360 361 return $tmp_file_exist && $running_process;362 }363 364 private function logProcessingErrorParameters($ret = [], $blogid_to_export = 0, $copymediabyshell = [], $shell_progress_key = '', $media_tmp_file = '')365 {366 do_action('prime_mover_log_processed_events', "shellMediaArchivingProcessRunning invalid parameters, bail out: ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);367 do_action('prime_mover_log_processed_events', "Ret variable: ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);368 do_action('prime_mover_log_processed_events', $ret, $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);369 do_action('prime_mover_log_processed_events', "Copy media by shell: ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);370 do_action('prime_mover_log_processed_events', $copymediabyshell, $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);371 do_action('prime_mover_log_processed_events', "Shell progress key: ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);372 do_action('prime_mover_log_processed_events', $shell_progress_key, $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);373 do_action('prime_mover_log_processed_events', "Media tmp file: ", $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);374 do_action('prime_mover_log_processed_events', $media_tmp_file, $blogid_to_export, 'export', 'shellMediaArchivingProcessRunning', $this);375 }376 /**377 * Returns TRUE if shell media is STOPPED378 * @param array $ret379 * @param array $copymediabyshell380 * @param string $media_tmp_file381 * @param string $shell_progress_key382 * @param number $blogid_to_export383 * @return boolean384 */385 public function shellMediaArchivingStopped($ret = [], $copymediabyshell = [], $media_tmp_file = '', $shell_progress_key = '', $blogid_to_export = 0)386 {387 $running = $this->shellMediaArchivingProcessRunning($ret, $copymediabyshell, $media_tmp_file, $shell_progress_key, $blogid_to_export );388 if ( ! $running ) {389 do_action('prime_mover_log_processed_events', "Shell media archiving STOPPED", $blogid_to_export, 'export', 'shellMediaArchivingStopped', $this);390 return true;391 } else {392 return false;393 }394 }395 396 /**397 * Returns TRUE if shell media archiving is COMPLETED398 * Otherwise false399 * @param array $copymediabyshell400 * @param array $ret401 * @param string $shell_progress_key402 * @param string $media_tmp_file403 * @return boolean404 */405 public function shellMediaArchivingCompleted($copymediabyshell = [], $ret = [], $shell_progress_key = '', $media_tmp_file = '')406 {407 return is_array($copymediabyshell) && isset($ret[$shell_progress_key]) && ! $this->getSystemFunctions()->nonCachedFileExists($media_tmp_file);408 }409 410 /**411 * Returns TRUE if shell media archving has not yet started412 * Otherwise FALSE413 * @param array $copymediabyshell414 * @param array $ret415 * @param string $shell_progress_key416 * @return boolean417 */418 public function shellMediaArchivingHasNotStarted($copymediabyshell = [], $ret = [], $shell_progress_key = '')419 {420 return (is_array($copymediabyshell) && ! isset($ret[$shell_progress_key]));421 }422 423 /**424 * Checks if we need to process using shell functions425 * @return boolean|string[]426 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itMaybeArchiveMediaByShell()427 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaByShellIfUnauthorized()428 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfFileSystemNotSet()429 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfSlowWebHost()430 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfWindows()431 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfNoExecFunctions()432 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfNoPHPExecutables()433 * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverCLIArchive::itDoesNotArchiveMediaShellIfNoCoreLoadFile()434 94 */ 435 95 public function maybeArchiveMediaByShell() 436 96 { 437 $this->getSystemInitialization()->initializeFs(false); 438 global $wp_filesystem; 439 440 if (! $this->getSystemAuthorization()->isUserAuthorized()) { 441 return false; 442 } 443 if ( ! $this->getSystemFunctions()->isWpFileSystemUsable($wp_filesystem) ) { 444 return false; 445 } 446 if (defined('PRIME_MOVER_SLOW_WEB_HOST') && true === PRIME_MOVER_SLOW_WEB_HOST) { 447 return false; 448 } 449 $parameters = []; 450 if ( $this->getSystemChecks()->isWindows()) { 451 return false; 452 } 453 454 if ( ! $this->getSystemChecks()->hasSystem()) { 455 return false; 456 } 457 $php_executable = $this->getPhpExecutable(); 458 if ( ! $php_executable ) { 459 return false; 460 } 461 462 $core_load_path = ABSPATH . 'wp-load.php'; 463 if ( ! $wp_filesystem->exists($core_load_path)) { 464 return false; 465 } 466 467 $parameters['executable'] = $php_executable; 468 $parameters['core_load_path'] = $core_load_path; 469 470 return $parameters; 471 } 472 473 /** 474 * Get PHP executable 475 * @return boolean|string 476 */ 477 protected function getPhpExecutable() 478 { 479 $phpinfo = $this->getShutDownUtilities()->phpinfo2array(); 480 if (empty($phpinfo['phpinfo']['PHP API']) || empty($phpinfo['phpinfo']['PHP Extension'])) { 481 return false; 482 } 483 $phpversion_web = phpversion(); 484 $php_api_web_version = $phpinfo['phpinfo']['PHP API']; 485 $php_extension_web_version = $phpinfo['phpinfo']['PHP Extension']; 486 487 $probable_executables = []; 488 $which_php = `which php`; 489 if ($which_php) { 490 $probable_executables[] = trim(`which php`); 491 } 492 if ( defined('PHP_BINDIR') && PHP_BINDIR) { 493 $probable_executables[] = trailingslashit(trim(PHP_BINDIR)) . 'php'; 494 } 495 if ( defined('PHP_BINARY') && PHP_BINARY) { 496 $probable_executables[] = trailingslashit(trim(PHP_BINARY)) . 'php'; 497 } 498 foreach ($probable_executables as $executable) { 499 if ( ! $this->getSystemChecks()->isExecutable($executable) ) { 500 continue; 501 } 502 $php_shell_info = shell_exec(escapeshellcmd("$executable -i")); 503 if ( ! $php_shell_info ) { 504 continue; 505 } 506 if (false !== strpos($php_shell_info, $phpversion_web) && false !== strpos($php_shell_info, $php_api_web_version) && 507 false !== strpos($php_shell_info, $php_extension_web_version)) { 508 return $executable; 509 } 510 } 511 return false; 512 } 513 514 /** 515 * Do Shell archiving related tasks 516 * @param array $copymediabyshell 517 * @param array $ret 518 * @param string $shell_progress_key 519 * @param number $blogid 520 * @param boolean $encrypt_media 521 * @param string $source 522 * @param string $mode 523 * @param string $zippath 524 * @param string $error_log_path 525 * @param string $media_tmp_file 526 * @param array $process_methods 527 * @param boolean $delete_source 528 * @param array $exclusion_rules 529 * @param string $task 530 * @param string $action 531 * @return array 532 */ 533 public function doShellArchivingTasks($copymediabyshell = [], $ret = [], $shell_progress_key = '', $blogid = 0, $encrypt_media = false, $source = '', $mode = 'media', $zippath = '', 534 $error_log_path = '', $media_tmp_file = '', $process_methods = [], $delete_source = false, $exclusion_rules = [], $task = '', $action = 'export') 535 { 536 $current = $process_methods['current']; 537 $previous = $process_methods['previous']; 538 $next = $process_methods['next']; 539 540 if ( ! $task ) { 541 $task = esc_html__('Archiving', 'prime-mover'); 542 } 543 544 if ($this->shellMediaArchivingHasRestarted($copymediabyshell, $ret, $shell_progress_key, $action) || $this->shellMediaArchivingHasNotStarted($copymediabyshell, $ret, $shell_progress_key)) { 545 546 $ret = $this->processShellRunTimeErrors($ret, $media_tmp_file, true, $blogid, $action, $task, $shell_progress_key); 547 if (isset($ret['error'])) { 548 return $ret; 549 } 550 551 do_action('prime_mover_log_processed_events', "$task $mode files in shell environment.", $blogid, $action, 'doShellArchivingTasks', $this); 552 $this->getProgressHandlers()->updateTrackerProgress(sprintf(esc_html__("$task %s via CLI", 'prime-mover'), $mode), $action); 553 $aux_data = $this->generateMediaArchivingArgumentsForShell($encrypt_media, $source, $zippath, $exclusion_rules, $blogid, $error_log_path, $delete_source, $mode, $action); 554 555 $ret = $this->executeCopyMediaShellCommand($ret, $copymediabyshell, $aux_data, $media_tmp_file, $shell_progress_key, $mode); 556 return apply_filters("prime_mover_save_return_{$action}_progress", $ret, $blogid, $current, $previous); 557 558 } elseif ($this->shellMediaArchivingProcessRunning($ret, $copymediabyshell, $media_tmp_file, $shell_progress_key, $blogid)) { 559 560 do_action('prime_mover_log_processed_events', "Copying and archiving is ONGOING in shell environment.", $blogid, $action, 'doShellArchivingTasks', $this); 561 return apply_filters("prime_mover_save_return_{$action}_progress", $ret, $blogid, $current, $previous); 562 563 } elseif ($this->shellMediaArchivingCompleted($copymediabyshell, $ret, $shell_progress_key, $media_tmp_file)) { 564 565 do_action('prime_mover_log_processed_events', "{$task} is now COMPLETED in shell environment.", $blogid, $action, 'doShellArchivingTasks', $this); 566 $ret = $this->getSystemFunctions()->doMemoryLogs($ret, $shell_progress_key, 'import', $action); 567 568 return apply_filters("prime_mover_save_return_{$action}_progress", $ret, $blogid, $next, $current); 569 570 } elseif ($this->shellMediaArchivingStopped($ret, $copymediabyshell, $media_tmp_file, $shell_progress_key, $blogid)) { 571 572 return $this->processShellRunTimeErrors($ret, $media_tmp_file, false, $blogid, $action, $task); 573 } 97 return false; 574 98 } 575 576 /**577 * Checks if CLI processing is restarted578 * @param array $copymediabyshell579 * @param array $ret580 * @param string $shell_progress_key581 * @param string $action582 * @return boolean583 */584 public function shellMediaArchivingHasRestarted($copymediabyshell = [], $ret = [], $shell_progress_key = '', $action = '')585 {586 $restarted = false;587 $cli_tmpname = '';588 589 if ( ! $action || ! $shell_progress_key) {590 return $restarted;591 }592 if (is_array($copymediabyshell) && $this->getSystemInitialization()->getProcessIdBasedOnGivenAction($action)) {593 $process_id = $this->getSystemInitialization()->getProcessIdBasedOnGivenAction($action);594 $cli_tmpname = $this->getSystemInitialization()->generateCliReprocessingTmpName($ret, $process_id, $shell_progress_key);595 }596 if ($cli_tmpname && $this->getSystemFunctions()->nonCachedFileExists($cli_tmpname)) {597 $restarted = true;598 }599 600 return $restarted;601 }602 603 /**604 * Process runtime shell errors605 * @param array $ret606 * @param string $media_tmp_file607 * @param boolean $strict_check608 * @param number $blogid609 * @param string $action610 * @param string $task611 * @param string $shell_progress_key612 * @return string613 */614 protected function processShellRunTimeErrors($ret = [], $media_tmp_file = '', $strict_check = false, $blogid = 0, $action = '', $task = '', $shell_progress_key = '')615 {616 if (! $this->getSystemAuthorization()->isUserAuthorized()) {617 return $ret;618 }619 do_action('prime_mover_log_processed_events', "{$task} is now STOPPED in shell environment.", $blogid, $action, 'doShellArchivingTasks', $this);620 621 $this->getSystemInitialization()->initializeFs(false);622 global $wp_filesystem;623 $shell_runtime_error = trim($wp_filesystem->get_contents($media_tmp_file));624 $note = esc_html__('ERROR: Shell process terminated =', 'prime-mover');625 626 if ($shell_runtime_error && false !== strpos($shell_runtime_error, 'prime-mover-shell-shutdown-error')) {627 $ret['error'] = $note . ' ' . $shell_runtime_error;628 } elseif ( ! $strict_check ) {629 $ret['error'] = $note . ' ' . sprintf(esc_html__('by your web host due to insufficient resources. Try adding this in wp-config.php to see if it helps: %s ', 'prime-mover'),630 'define("PRIME_MOVER_SLOW_WEB_HOST", true);');631 }632 if ( ! empty($ret['error']) ) {633 $this->maybeDeleteCliRestartTmpFile($action, $ret, $shell_progress_key);634 $wp_filesystem->delete($media_tmp_file);635 }636 637 return $ret;638 }639 640 /**641 * Maybe delete CLI restart tmp file642 * @param string $action643 * @param array $ret644 * @param string $shell_progress_key645 */646 protected function maybeDeleteCliRestartTmpFile($action = '', $ret = [], $shell_progress_key = '')647 {648 $this->getSystemInitialization()->initializeFs(false);649 global $wp_filesystem;650 $process_id = $this->getSystemInitialization()->getProcessIdBasedOnGivenAction($action);651 $cli_tmpname = $this->getSystemInitialization()->generateCliReprocessingTmpName($ret, $process_id, $shell_progress_key);652 653 if ($cli_tmpname && $this->getSystemFunctions()->nonCachedFileExists($cli_tmpname)) {654 $wp_filesystem->delete($cli_tmpname);655 }656 }657 658 /**659 * Initialize master tmp files660 * @param array $ret661 * @return array662 */663 public function initializeMasterTmpFiles($ret = [])664 {665 if (! $this->getSystemAuthorization()->isUserAuthorized() || empty($ret['original_blogid'])) {666 return $ret;667 }668 $copymediabyshell = $this->maybeArchiveMediaByShell();669 if ( ! $copymediabyshell ) {670 return $ret;671 }672 $ret['master_tmp_shell_files'] = wp_normalize_path($this->getSystemInitialization()->wpTempNam());673 $ret['master_tmp_shell_dirs'] = wp_normalize_path($this->getSystemInitialization()->wpTempNam());674 675 $blog_id = $ret['original_blogid'];676 $values = [$ret['master_tmp_shell_files'], $ret['master_tmp_shell_dirs']];677 678 $option = $this->getSystemInitialization()->getCliMasterTmpFilesOptions() . "_" . $blog_id;679 $this->getSystemFunctions()->updateSiteOption($option, $values, true, '', true, true);680 681 return $ret;682 }683 99 684 100 /** -
prime-mover/trunk/compatibility/PrimeMoverFreemiusCompat.php
r3301867 r3485190 341 341 $freemius->add_filter('pricing_url', [$this, 'filterUpgradeUrl'], 10, 1); 342 342 $freemius->add_filter('show_trial', [$this, 'maybehideTrial'], 10, 1); 343 $freemius->add_action('account_page_load_before_departure', [$this, 'maybeRestoreCurrentBlog']); 344 } 345 346 /** 347 * Hotfix for Freemius switching blogs during account edits, but never called restore current blog. 348 * Ideally, this permanent fix should be added to Freemius. 349 */ 350 public function maybeRestoreCurrentBlog() 351 { 352 if (is_multisite() && is_network_admin() && ms_is_switched()) { 353 restore_current_blog(); 354 } 343 355 } 344 356 -
prime-mover/trunk/engines/prime-mover-panel/prime-mover-panel.php
r3455709 r3485190 43 43 } 44 44 define( 'PRIME_MOVER_PANEL_PLUGINPATH', plugin_dir_path( __FILE__ ) ); 45 define( 'PRIME_MOVER_PANEL_VERSION', '2.1. 2' );45 define( 'PRIME_MOVER_PANEL_VERSION', '2.1.3' ); 46 46 define( 'PRIME_MOVER_PANEL_MAINPLUGIN_FILE', __FILE__ ); 47 47 define( 'PRIME_MOVER_PANEL_PLUGINBASENAME', plugin_basename( PRIME_MOVER_PANEL_MAINPLUGIN_FILE ) ); -
prime-mover/trunk/engines/prime-mover-panel/vendor/composer/installed.php
r3455709 r3485190 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 5772634322078d8040aee84cf1161f40e30c2854',6 'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => ' 5772634322078d8040aee84cf1161f40e30c2854',16 'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
prime-mover/trunk/global/PrimeMoverGlobalConstants.php
r3455709 r3485190 9 9 } 10 10 11 define('PRIME_MOVER_VERSION', '2.1. 2');11 define('PRIME_MOVER_VERSION', '2.1.3'); 12 12 define('PRIME_MOVER_PLUGIN_CODENAME', 'Prime Mover'); 13 13 define('PRIME_MOVER_PRO_PLUGIN_CODENAME', 'Prime Mover PRO'); -
prime-mover/trunk/global/PrimeMoverGlobalFunctions.php
r3315519 r3485190 21 21 require_once PRIME_MOVER_MAINDIR . '/freemius/start.php'; 22 22 $pm_fs = fs_dynamic_init( array( 23 'id' => '3826',24 'slug' => 'prime-mover',25 'premium_slug' => 'prime-mover-pro',26 'type' => 'plugin',27 'public_key' => 'pk_a69fd5401be20bf46608b1c38165b',28 'is_premium' => false,29 'premium_suffix' => 'Pro',30 'has_addons' => false,31 'has_paid_plans' => true,32 'trial' => array(23 'id' => '3826', 24 'slug' => 'prime-mover', 25 'premium_slug' => 'prime-mover-pro', 26 'type' => 'plugin', 27 'public_key' => 'pk_a69fd5401be20bf46608b1c38165b', 28 'is_premium' => false, 29 'premium_suffix' => 'Pro', 30 'has_addons' => false, 31 'has_paid_plans' => true, 32 'trial' => array( 33 33 'days' => 14, 34 34 'is_require_payment' => true, 35 35 ), 36 'menu' => array(36 'menu' => array( 37 37 'slug' => 'migration-panel-settings', 38 38 'network' => true, 39 39 ), 40 'is_live' => true, 40 'is_live' => true, 41 'is_org_compliant' => true, 41 42 ) ); 42 43 } -
prime-mover/trunk/prime-mover.php
r3455709 r3485190 5 5 Plugin URI: https://codexonics.com/ 6 6 Description: The simplest all-around WordPress migration tool/backup plugin. These support multisite backup/migration or clone WP site/multisite subsite. 7 Version: 2.1. 27 Version: 2.1.3 8 8 Author: Codexonics 9 9 Author URI: https://codexonics.com/ -
prime-mover/trunk/readme.txt
r3455709 r3485190 4 4 Tags: migrate wordpress, multisite migration, clone, backup 5 5 Requires at least: 4.9.8 6 Tested up to: 6.96 Tested up to: 7.0 7 7 Requires PHP: 5.6 8 Stable tag: 2.1. 28 Stable tag: 2.1.3 9 9 License: GPLv3 or later 10 10 License URI: https://codexonics.com … … 81 81 * You can save, download, delete, and migrate packages using the management page. 82 82 * No need to worry about PHP configuration and server settings. Compatible with most default PHP server settings, even in limited shared hosting. 83 * Prime Mover works with modern PHP versions 5.6 to 8. 4+ (Google Drive feature requires at least PHP 7.4).83 * Prime Mover works with modern PHP versions 5.6 to 8.5+ (Google Drive feature requires at least PHP 7.4). 84 84 * The code follows PHP-fig coding standards (standard PHP coding guidelines). 85 85 * The free version supports backup and restoration of non-UTF8 sites. However, you need the PRO version to migrate non-UTF8 to the UTF8 (utf8mb4) database charset and vice versa. … … 106 106 == Changelog == 107 107 108 = 2.1.3 = 109 110 * Fixed: Edge case fatal error when activating or deactivating a license on the Freemius account page with specialized themes. 111 * Fixed: Update MySQLdump library for compatibility with PHP 8.5. 112 * Fixed: General compatibility fixes with PHP 8.5. 113 * Fixed: Removed outdated, deprecated code. 114 * Fixed: Removed the use of PHP shell functions. 115 * Fixed: Updated Dropbox library for PHP 8.5 compatibility. 116 * Fixed: Tested for compatibility with WordPress 7.0. 117 108 118 = 2.1.2 = 109 119 … … 126 136 * Compatibility: Tested with WordPress 6.9 release. 127 137 128 = 2.1.0 =129 130 * Fixed: Deprecated notices in the PHP 8.4 latest version.131 * Fixed: Outdated libraries to work in PHP 8.4.132 * Fixed: Updated all third-party libraries to work from PHP 5.6 to PHP 8.4.133 * Fixed: Updated the Freemius SDK to version 2.12.2.134 135 138 See the previous changelogs in changelog.txt. -
prime-mover/trunk/vendor/autoload.php
r3374030 r3485190 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 13ccde415249de5d5934c6d5dc37d38d::getLoader();25 return ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c::getLoader(); -
prime-mover/trunk/vendor/composer/autoload_classmap.php
r3301867 r3485190 72 72 'Codexonics\\PrimeMoverFramework\\classes\\PrimeMoverValidationHandlers' => $baseDir . '/classes/PrimeMoverValidationHandlers.php', 73 73 'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIArchive' => $baseDir . '/cli/PrimeMoverCLIArchive.php', 74 'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIShellArchiver' => $baseDir . '/cli/PrimeMoverCLIShellArchiver.php',75 74 'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverBuddyPressCompat' => $baseDir . '/compatibility/PrimeMoverBuddyPressCompat.php', 76 75 'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverCachingCompat' => $baseDir . '/compatibility/PrimeMoverCachingCompat.php', -
prime-mover/trunk/vendor/composer/autoload_real.php
r3374030 r3485190 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 13ccde415249de5d5934c6d5dc37d38d5 class ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 13ccde415249de5d5934c6d5dc37d38d', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 13ccde415249de5d5934c6d5dc37d38d', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 13ccde415249de5d5934c6d5dc37d38d::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
prime-mover/trunk/vendor/composer/autoload_static.php
r3374030 r3485190 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 13ccde415249de5d5934c6d5dc37d38d7 class ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c 8 8 { 9 9 public static $classMap = array ( … … 73 73 'Codexonics\\PrimeMoverFramework\\classes\\PrimeMoverValidationHandlers' => __DIR__ . '/../..' . '/classes/PrimeMoverValidationHandlers.php', 74 74 'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIArchive' => __DIR__ . '/../..' . '/cli/PrimeMoverCLIArchive.php', 75 'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIShellArchiver' => __DIR__ . '/../..' . '/cli/PrimeMoverCLIShellArchiver.php',76 75 'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverBuddyPressCompat' => __DIR__ . '/../..' . '/compatibility/PrimeMoverBuddyPressCompat.php', 77 76 'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverCachingCompat' => __DIR__ . '/../..' . '/compatibility/PrimeMoverCachingCompat.php', … … 173 172 { 174 173 return \Closure::bind(function () use ($loader) { 175 $loader->classMap = ComposerStaticInit 13ccde415249de5d5934c6d5dc37d38d::$classMap;174 $loader->classMap = ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c::$classMap; 176 175 177 176 }, null, ClassLoader::class); -
prime-mover/trunk/vendor/composer/installed.php
r3455709 r3485190 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 5772634322078d8040aee84cf1161f40e30c2854',6 'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => ' 5772634322078d8040aee84cf1161f40e30c2854',16 'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.