Plugin Directory

Changeset 3485190


Ignore:
Timestamp:
03/18/2026 12:13:37 AM (9 days ago)
Author:
codexonics
Message:

Updated trunk for version 2.1.3

Location:
prime-mover/trunk
Files:
2 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • prime-mover/trunk/PrimeMoverFactory.php

    r3400102 r3485190  
    4242use Codexonics\PrimeMoverFramework\streams\PrimeMoverResumableDownloadStream;
    4343use Codexonics\PrimeMoverFramework\streams\PrimeMoverIterators;
    44 use Codexonics\PrimeMoverFramework\cli\PrimeMoverCLIShellArchiver;
    4544use Codexonics\PrimeMoverFramework\cli\PrimeMoverCLIArchive;
    4645use Codexonics\PrimeMoverFramework\menus\PrimeMoverBackupMenus;
     
    7675 */
    7776class 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);
    10184    }
    102        
    103     /**
    104      * Get Cli
    105      * @return boolean
    106      */
    107     public function getCli()
    108     {
    109         return $this->cli;
    110     }
    111    
    112     /**
    113      * Get parameters
    114      * @return array
    115      */
    116     public function getParameters()
    117     {
    118         return $this->parameters;
    119     }
    120        
    121     /**
    122      * Initialize hook
    123      */
    124     public function initHook()
    125     {
    126         add_action('init', [$this, 'composeObjects'], 0);
    127         add_filter( 'determine_current_user', [$this, 'setUser'], 10, 1 );
    128     }
    12985   
    13086    /**
     
    146102       
    147103        $this->removePluginManagerOnUninstall();
    148     }
    149    
    150     /**
    151      * Set user if needed
    152      * @param mixed $user
    153      * @return mixed
    154      */
    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;       
    161104    }
    162105   
     
    306249       
    307250        $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();   
    315252               
    316253        $backup_menu = new PrimeMoverBackupMenus($prime_mover, $utilities);
     
    591528/**
    592529 * Instantiate
    593  * @var \Codexonics\PrimeMoverFactory $loaded_instance
    594530 */
    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();
    607532$loaded_instance->initHook();
    608533$loaded_instance->loadActivationHook();
  • prime-mover/trunk/build/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php

    r3176508 r3485190  
    152152        $this->pass = $pass;
    153153        $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        }
    154167        // 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;
    157170        }
    158171        $this->pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
  • prime-mover/trunk/changelog.txt

    r3455709 r3485190  
    22
    33**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.
    411
    512= 2.0.9 =
  • prime-mover/trunk/classes/PrimeMoverErrorHandlers.php

    r3400102 r3485190  
    351351            return $error_output;
    352352        }
    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();       
    363355        $error_output = array_merge($error_output, $phpinfoarray);       
    364356       
  • prime-mover/trunk/classes/PrimeMoverExporter.php

    r3455709 r3485190  
    10011001           
    10021002            $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        }
    10101005       
    10111006        return $dump_result;
     
    10421037   
    10431038    /**
    1044      * @tested Codexonics\PrimeMoverFramework\Tests\TestPrimeMoverExporter::itChecksWhetherToUseMySQLDumpPHP()
    1045      * Maybe use MySQL Dump PHP if shell isn't supported
    1046      * @param array $ret
    1047      * @return boolean
    1048      * @deprecated
    1049      */
    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     /**
    10681039     * Checks if dump is in progress
    10691040     * @param array $ret
     
    10791050        $this->getSystemInitialization()->setSlowProcess();
    10801051        return $dump_in_progress;
    1081     }
    1082    
    1083     /**
    1084      * MySQL dump using shell
    1085      * @param array $tables_to_dumped_shell
    1086      * @param boolean $filter_export_data
    1087      * @param string $target_path
    1088      * @param number $blogid_to_export
    1089      * @param array $ret
    1090      * @param number $db_dump_start
    1091      * @return boolean
    1092      */
    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 supported
    1164      * @param string $command
    1165      * @param boolean $filter_export_data
    1166      * @param string $target_path
    1167      * @return array
    1168      *
    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;
    12181052    }
    12191053
     
    13901224   
    13911225    /**
    1392      * Generate MySQL dump shell command
    1393      * @param array $ret
    1394      * @param number $blogid_to_export
    1395      * @param array $clean_tables
    1396      * @return mixed
    1397      *
    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     /**
    14911226     * Count all table rows
    14921227     * @param array $tables
  • prime-mover/trunk/classes/PrimeMoverImporter.php

    r3455709 r3485190  
    602602        do_action('prime_mover_log_processed_events', "Extract main package..start", $blogid_to_import, 'import', $process_methods['current'], $this);         
    603603       
    604         $copymediabyshell = $this->getCliArchiver()->maybeArchiveMediaByShell();
    605604        $extracting_tar = false;
    606605        if (!empty($ret['file']) && $wp_filesystem->exists($ret['file']) && $this->getSystemFunctions()->hasTarExtension($ret['file'])) {
     
    609608        $ret['is_extracting_tar'] = $extracting_tar;
    610609        $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           
    620611        if ( ! isset($ret['file'] ) || ! $wp_filesystem->exists($ret['file'])) {
    621612            if (! isset($ret[$shell_progress_key]) && !$extracting_tar) {
     
    649640        }
    650641       
    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) {           
    659644            if (empty($ret['media_zip_last_index'])) {
    660645                $ret['media_zip_last_index'] = 0;
  • prime-mover/trunk/classes/PrimeMoverSystemChecks.php

    r3455709 r3485190  
    947947        return $actions;
    948948    }
    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.6
    955      * @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() possible
    968         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 works
    988         foreach ($paths as $path) {
    989             if ($this->isExecutable($path)) {
    990                 return $path;
    991             }
    992         }
    993        
    994         return false;
    995     }   
    996949       
    997950    /**
     
    1003956        return @is_executable($path);
    1004957    }   
    1005        
    1006     /**
    1007      * Can system() be called on this server
    1008      * Modified from Snap Creek | https://wordpress.org/plugins/duplicator/
    1009      * @return bool Returns true if system() can be called on server
    1010      * @compatible 5.6
    1011      *
    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     }
    1036958 
    1037959    /**
  • prime-mover/trunk/classes/PrimeMoverSystemInitialization.php

    r3455709 r3485190  
    9191    private $is_legacy;
    9292   
    93     /** @var array coresystem_functions */
    94     private $coresystem_functions;
    95    
    9693    /** @var string base backup directory */
    9794    private $basebackupdir;
     
    307304        $this->export_zip_path =  '';
    308305        $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;       
    311307        $this->download_url = '';
    312308       
     
    13601356        return $this->download_url;
    13611357    }
    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       
    13741359    /**
    13751360     * Get System authorization
  • prime-mover/trunk/cli/PrimeMoverCLIArchive.php

    r3455709 r3485190  
    1414use Codexonics\PrimeMoverFramework\classes\PrimeMoverSystemChecks;
    1515use Codexonics\PrimeMoverFramework\classes\PrimeMoverProgressHandlers;
    16 
    17 /**
    18  * ZIP ARCHIVER CLASS FOR COMMAND LINE
    19  * @since 1.0.7
    20  */
    2116
    2217if (! defined('ABSPATH')) {
     
    4136    }   
    4237   
    43     /**
     38     /**
    4439     * Get shutdown utilities
    4540     * @return \Codexonics\PrimeMoverFramework\utilities\PrimeMoverShutdownUtilities
     
    9388        return $this->progress_handlers;
    9489    }
    95    
     90       
    9691    /**
    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.
    23893     * @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 events
    251      */
    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 caller
    265      * @param string $given_executable
    266      * @param string $given_script
    267      * @param number $blog_id
    268      * @return boolean
    269      */
    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 running
    296      * Linux only
    297      * @param number $process_id
    298      * @return boolean
    299      */
    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 variable
    310          */
    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 export
    322      * @param array $ret
    323      * @param array $copymediabyshell
    324      * @param string $media_tmp_file
    325      * @param string $shell_progress_key
    326      * @param number $blogid_to_export
    327      * @return boolean
    328      */
    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 STOPPED
    378      * @param array $ret
    379      * @param array $copymediabyshell
    380      * @param string $media_tmp_file
    381      * @param string $shell_progress_key
    382      * @param number $blogid_to_export
    383      * @return boolean
    384      */
    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 COMPLETED
    398      * Otherwise false
    399      * @param array $copymediabyshell
    400      * @param array $ret
    401      * @param string $shell_progress_key
    402      * @param string $media_tmp_file
    403      * @return boolean
    404      */
    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 started
    412      * Otherwise FALSE
    413      * @param array $copymediabyshell
    414      * @param array $ret
    415      * @param string $shell_progress_key
    416      * @return boolean
    417      */
    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 functions
    425      * @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()
    43494     */
    43595    public function maybeArchiveMediaByShell()
    43696    {
    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;
    57498    }
    575    
    576      /**
    577      * Checks if CLI processing is restarted
    578      * @param array $copymediabyshell
    579      * @param array $ret
    580      * @param string $shell_progress_key
    581      * @param string $action
    582      * @return boolean
    583      */
    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 errors
    605      * @param array $ret
    606      * @param string $media_tmp_file
    607      * @param boolean $strict_check
    608      * @param number $blogid
    609      * @param string $action
    610      * @param string $task
    611      * @param string $shell_progress_key
    612      * @return string
    613      */
    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 file
    642      * @param string $action
    643      * @param array $ret
    644      * @param string $shell_progress_key
    645      */
    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 files
    660      * @param array $ret
    661      * @return array
    662      */
    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     }
    68399   
    684100    /**
  • prime-mover/trunk/compatibility/PrimeMoverFreemiusCompat.php

    r3301867 r3485190  
    341341        $freemius->add_filter('pricing_url', [$this, 'filterUpgradeUrl'], 10, 1);
    342342        $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        }
    343355    }
    344356   
  • prime-mover/trunk/engines/prime-mover-panel/prime-mover-panel.php

    r3455709 r3485190  
    4343}
    4444define( 'PRIME_MOVER_PANEL_PLUGINPATH', plugin_dir_path( __FILE__ ) );
    45 define( 'PRIME_MOVER_PANEL_VERSION', '2.1.2' );
     45define( 'PRIME_MOVER_PANEL_VERSION', '2.1.3' );
    4646define( 'PRIME_MOVER_PANEL_MAINPLUGIN_FILE', __FILE__ );
    4747define( 'PRIME_MOVER_PANEL_PLUGINBASENAME', plugin_basename( PRIME_MOVER_PANEL_MAINPLUGIN_FILE ) );
  • prime-mover/trunk/engines/prime-mover-panel/vendor/composer/installed.php

    r3455709 r3485190  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '5772634322078d8040aee84cf1161f40e30c2854',
     6        'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '5772634322078d8040aee84cf1161f40e30c2854',
     16            'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • prime-mover/trunk/global/PrimeMoverGlobalConstants.php

    r3455709 r3485190  
    99}
    1010
    11 define('PRIME_MOVER_VERSION', '2.1.2');
     11define('PRIME_MOVER_VERSION', '2.1.3');
    1212define('PRIME_MOVER_PLUGIN_CODENAME', 'Prime Mover');
    1313define('PRIME_MOVER_PRO_PLUGIN_CODENAME', 'Prime Mover PRO');
  • prime-mover/trunk/global/PrimeMoverGlobalFunctions.php

    r3315519 r3485190  
    2121            require_once PRIME_MOVER_MAINDIR . '/freemius/start.php';
    2222            $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(
    3333                    'days'               => 14,
    3434                    'is_require_payment' => true,
    3535                ),
    36                 'menu'           => array(
     36                'menu'             => array(
    3737                    'slug'    => 'migration-panel-settings',
    3838                    'network' => true,
    3939                ),
    40                 'is_live'        => true,
     40                'is_live'          => true,
     41                'is_org_compliant' => true,
    4142            ) );
    4243        }
  • prime-mover/trunk/prime-mover.php

    r3455709 r3485190  
    55Plugin URI: https://codexonics.com/
    66Description: The simplest all-around WordPress migration tool/backup plugin. These support multisite backup/migration or clone WP site/multisite subsite.
    7 Version: 2.1.2
     7Version: 2.1.3
    88Author: Codexonics
    99Author URI: https://codexonics.com/
  • prime-mover/trunk/readme.txt

    r3455709 r3485190  
    44Tags: migrate wordpress, multisite migration, clone, backup
    55Requires at least: 4.9.8
    6 Tested up to: 6.9
     6Tested up to: 7.0
    77Requires PHP: 5.6
    8 Stable tag: 2.1.2
     8Stable tag: 2.1.3
    99License: GPLv3 or later
    1010License URI: https://codexonics.com
     
    8181* You can save, download, delete, and migrate packages using the management page.
    8282* 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).
    8484* The code follows PHP-fig coding standards (standard PHP coding guidelines).
    8585* 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.
     
    106106== Changelog ==
    107107
     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
    108118= 2.1.2 =
    109119
     
    126136* Compatibility: Tested with WordPress 6.9 release.
    127137
    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 
    135138See the previous changelogs in changelog.txt.
  • prime-mover/trunk/vendor/autoload.php

    r3374030 r3485190  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit13ccde415249de5d5934c6d5dc37d38d::getLoader();
     25return ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c::getLoader();
  • prime-mover/trunk/vendor/composer/autoload_classmap.php

    r3301867 r3485190  
    7272    'Codexonics\\PrimeMoverFramework\\classes\\PrimeMoverValidationHandlers' => $baseDir . '/classes/PrimeMoverValidationHandlers.php',
    7373    'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIArchive' => $baseDir . '/cli/PrimeMoverCLIArchive.php',
    74     'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIShellArchiver' => $baseDir . '/cli/PrimeMoverCLIShellArchiver.php',
    7574    'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverBuddyPressCompat' => $baseDir . '/compatibility/PrimeMoverBuddyPressCompat.php',
    7675    'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverCachingCompat' => $baseDir . '/compatibility/PrimeMoverCachingCompat.php',
  • prime-mover/trunk/vendor/composer/autoload_real.php

    r3374030 r3485190  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit13ccde415249de5d5934c6d5dc37d38d
     5class ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit13ccde415249de5d5934c6d5dc37d38d', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit13ccde415249de5d5934c6d5dc37d38d', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInitfd3fb9e59f54f0ffca2971b8e1818a7c', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit13ccde415249de5d5934c6d5dc37d38d::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c::getInitializer($loader));
    3131
    3232        $loader->register(true);
  • prime-mover/trunk/vendor/composer/autoload_static.php

    r3374030 r3485190  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit13ccde415249de5d5934c6d5dc37d38d
     7class ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c
    88{
    99    public static $classMap = array (
     
    7373        'Codexonics\\PrimeMoverFramework\\classes\\PrimeMoverValidationHandlers' => __DIR__ . '/../..' . '/classes/PrimeMoverValidationHandlers.php',
    7474        'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIArchive' => __DIR__ . '/../..' . '/cli/PrimeMoverCLIArchive.php',
    75         'Codexonics\\PrimeMoverFramework\\cli\\PrimeMoverCLIShellArchiver' => __DIR__ . '/../..' . '/cli/PrimeMoverCLIShellArchiver.php',
    7675        'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverBuddyPressCompat' => __DIR__ . '/../..' . '/compatibility/PrimeMoverBuddyPressCompat.php',
    7776        'Codexonics\\PrimeMoverFramework\\compatibility\\PrimeMoverCachingCompat' => __DIR__ . '/../..' . '/compatibility/PrimeMoverCachingCompat.php',
     
    173172    {
    174173        return \Closure::bind(function () use ($loader) {
    175             $loader->classMap = ComposerStaticInit13ccde415249de5d5934c6d5dc37d38d::$classMap;
     174            $loader->classMap = ComposerStaticInitfd3fb9e59f54f0ffca2971b8e1818a7c::$classMap;
    176175
    177176        }, null, ClassLoader::class);
  • prime-mover/trunk/vendor/composer/installed.php

    r3455709 r3485190  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '5772634322078d8040aee84cf1161f40e30c2854',
     6        'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '5772634322078d8040aee84cf1161f40e30c2854',
     16            'reference' => 'f959bac6a1ee76d33f3f4b5c9763ced042c68ccd',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.