Plugin Directory

Changeset 3374608


Ignore:
Timestamp:
10/07/2025 05:50:15 PM (5 months ago)
Author:
1clickmigration
Message:

Update to version 2.3.1

Location:
1-click-migration/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 1-click-migration/trunk/inc/background/class-background-helper.php

    r2414581 r3374608  
    1717        }
    1818
    19         $wpdb->get_results($wpdb->prepare("DELETE FROM {$table} where {$column} LIKE 'wp_ocm_background_%_batch_%'", []));
    20         $wpdb->get_results($wpdb->prepare("DELETE FROM {$table} where {$column} LIKE '_transient_%'", []));
    21         $wpdb->get_results($wpdb->prepare("DELETE FROM {$table} where {$column} LIKE '_site_transient_%'", []));
    22         $wpdb->get_results($wpdb->prepare("DELETE FROM {$table} where {$column} = 'backup_steps'", []));
    23         $wpdb->get_results($wpdb->prepare("DELETE FROM {$table} where {$column} = 'restore_steps'", []));
     19        $wpdb->get_results("DELETE FROM {$table} where {$column} LIKE 'wp_ocm_background_%_batch_%'");
     20        $wpdb->get_results("DELETE FROM {$table} where {$column} LIKE '_transient_%'");
     21        $wpdb->get_results("DELETE FROM {$table} where {$column} LIKE '_site_transient_%'");
     22        $wpdb->get_results("DELETE FROM {$table} where {$column} = 'backup_steps'");
     23        $wpdb->get_results("DELETE FROM {$table} where {$column} = 'restore_steps'");
    2424    }
    2525
  • 1-click-migration/trunk/inc/backup/class-ocm-backup.php

    r3372639 r3374608  
    7272        ['Current IP Address', '1%'],
    7373        ['Creating temporary directory', '1%'],
     74
     75
     76        ['URL generated: db', '5%'],
     77        ['URL generated: uploads', '9%'],
     78        ['URL generated: themes', '14%'],
     79        ['URL generated: plugins', '18%'],
     80        ['URL generated: log', '23%'],
     81        ['URL generated: log_download', '27%'],
    7482
    7583
     
    235243        ['Notice: file db.zip.crypt not found', '60%'],
    236244
    237         ['Themes have been restored', '92%'],
    238         ['Uploads have been restored', '94%'],
    239         ['Plugins have been restored', '96%'],
     245        ['Themes have been restored', '64%'],
     246        ['Uploads have been restored', '64%'],
     247        ['Plugins have been restored', '64%'],
    240248
    241249        ['Restore plugins', '75%'],
    242250        ['Please make payment before the restore can complete', '77%'],
    243251        ['Notice: Database restore in progress. Please don\'t leave the plugin page.', '80%'],
    244         ['Database has been restored', '98%'],
    245         ['Starting to update URLs in database', '99%'],
    246         ['Cleaning up.', '99%'],
     252        ['Database has been restored', '83%'],
     253        ['Starting to update URLs in database', '84%'],
     254        ['Cleaning up.', '92%'],
    247255        ['Restore completed.', '100%'],
    248256        ['Error:', '0%'],
     
    329337        $bucket_key = self::get_bucket_key($username, $password);
    330338        $excluded_folders = self::get_excluded_folders();
     339       
     340        // Try to create bucket and get presigned URLs with retry logic
    331341        $presigned_urls = OCM_S3::s3_create_bucket_ifnot_exists($bucket_key);
     342       
     343        // If bucket was just created, the URLs might not be immediately available
     344        // Retry up to 3 times with a 2-second delay between attempts
     345        $retry_count = 0;
     346        $max_retries = 3;
     347       
     348        while (!$presigned_urls && $retry_count < $max_retries) {
     349            $retry_count++;
     350            One_Click_Migration::write_to_log("Bucket created, waiting for presigned URLs (attempt $retry_count/$max_retries)...");
     351            sleep(2); // Wait 2 seconds for bucket to be fully initialized
     352            $presigned_urls = OCM_S3::s3_create_bucket_ifnot_exists($bucket_key);
     353        }
     354       
    332355        $prev_bucket_key = get_option('ocm_bucket_key');
    333356
     
    346369
    347370        if (!$presigned_urls) {
    348             One_Click_Migration::write_to_log('Error: Backup does not exist');
     371            One_Click_Migration::write_to_log('Error: Could not get presigned URLs after ' . ($retry_count + 1) . ' attempts');
    349372            wp_safe_redirect(admin_url('tools.php?page=one-click-migration&message=endpoint_failure'));
    350373            exit;
     
    472495        update_option('ocm_is_stopped', false, true);
    473496
    474         // Enable maintenance mode for the restore process
    475         One_Click_Migration::enable_maintenance_mode();
     497
    476498
    477499        $content_dir = WP_CONTENT_DIR . '/ocm_restore';
     
    516538              }
    517539
    518               // Debug: Log all generated URLs to see the mapping
    519               One_Click_Migration::write_to_log("DEBUG: Generated URL for '$key': " . $generated_url);
    520540            }
    521541
     
    536556        }
    537557
    538         // Try to get presigned URLs from restore steps first, fallback to option
    539558        $presigned_urls = self::get_restore_step_value('init', self::STEP_RESTORE_CHILD_PRESIGNED_URLS);
    540        
    541         // If restore steps method fails, try getting from option directly
    542         if (!$presigned_urls) {
    543             One_Click_Migration::write_to_log('DEBUG: Restore steps method failed, trying option method');
    544             $presigned_urls = get_option('ocm_presigned_urls');
    545         }
    546        
    547         // Convert stdClass object to array if needed (WordPress sometimes converts arrays to objects)
    548         if (is_object($presigned_urls)) {
    549             One_Click_Migration::write_to_log('DEBUG: Converting stdClass object to array');
    550             $presigned_urls = (array) $presigned_urls;
    551         }
    552        
    553559        $excluded_folders = self::get_excluded_folders();
    554 
    555         // Debug: Log presigned URLs status
    556         One_Click_Migration::write_to_log('DEBUG: Retrieved presigned URLs: ' . (is_null($presigned_urls) ? 'NULL' : 'NOT NULL'));
    557         if (!is_null($presigned_urls)) {
    558             One_Click_Migration::write_to_log('DEBUG: Presigned URLs count: ' . (is_array($presigned_urls) ? count($presigned_urls) : 'NOT ARRAY'));
    559         }
    560 
    561         // Check if presigned URLs are available
    562         if (!$presigned_urls || !is_array($presigned_urls)) {
    563             One_Click_Migration::write_to_log('Error: No presigned URLs available for download');
    564             One_Click_Migration::write_to_log('DEBUG: Available restore steps: ' . print_r(self::get_current_restore_steps(), true));
    565             update_option('ocm_is_stopped', true, true);
    566             exit;
    567         }
    568 
    569         // Clear excluded files list before starting downloads (but after URLs are retrieved)
    570         delete_option('ocm_excluded_folders');
    571         delete_option('ocm_skipped_folders');
    572         delete_option('ocm_eexcluded_folders');
    573         One_Click_Migration::write_to_log('DEBUG: Cleared excluded files list for fresh restore attempt');
    574560
    575561        // Download each of the zip files
     
    629615
    630616
    631 
    632                     // Debug: Log the download URL for database files
    633                     if ($key === 'db') {
    634                         One_Click_Migration::write_to_log("DEBUG: Attempting to download database from URL: " . $download_url);
    635                     }
    636 
    637617                    $downloadTmpPathFile = download_url($download_url, One_Click_Migration::$process_restore_single->remaining_time());
    638618
    639619                    if(is_wp_error($downloadTmpPathFile)){
    640620                      $error_message = $downloadTmpPathFile->get_error_message();
    641                      
    642                       // Debug: Log detailed error for database files
    643                       if ($key === 'db') {
    644                           One_Click_Migration::write_to_log("DEBUG: Database download failed with error: " . $error_message);
    645                           One_Click_Migration::write_to_log("DEBUG: Full WP_Error object: " . print_r($downloadTmpPathFile, true));
    646                       }
    647                      
    648621                      if($error_message === 'Not Found'){
    649622
     
    656629
    657630                        continue;
    658                       } else {
    659                         // Handle other download errors
    660                         One_Click_Migration::write_to_log("Download failed for $key: $error_message");
    661                         update_option('ocm_is_stopped', true, true);
    662                         exit;
    663631                      }
    664632                    }
     
    872840                            // Fallback: Try copying files instead of moving
    873841                            if (!self::copyDirectory($extract_path, $directory)) {
    874                                 self::handle_restore_error(sprintf(
     842                                One_Click_Migration::write_to_log(sprintf(
    875843                                    'Downloading restore files. Error: "%s" directory could not be moved or copied to "%s" directory. Please check the write permission for these directories.',
    876844                                    $extract_path, $directory
    877845                                ));
     846
     847                                update_option('ocm_is_stopped', true, true);
     848                                die();
    878849                            }
    879850                        }
     
    930901
    931902        }
    932         if(!in_array('db', $excluded_restore_files)){
    933           // Database is not excluded, so we need to restore it
    934           // This requires payment for database restore
     903        if(in_array('db', $excluded_restore_files)){
     904          self::complete_restore();
     905        }else{
    935906          One_Click_Migration::write_to_log('Please make payment before the restore can complete');
    936         }else{
    937           // Database is excluded, so we can complete the restore without it
    938           self::complete_restore();
    939907        }
    940908
     
    963931            // Delete ocm_restore folder
    964932              if (file_exists($ocmRestoreDir) && !rmdir($ocmRestoreDir)) {
    965                 self::handle_restore_error(sprintf(
     933                One_Click_Migration::write_to_log(sprintf(
    966934                    'Cleaning up "ocm_restore" directory. Error: "%s" directory could not be deleted. Please check the write permission for this directory or the parent directory.',
    967935                    $ocmRestoreDir
    968936                ));
     937
     938                update_option('ocm_is_stopped', true, true);
     939                exit;
    969940            }
    970941          }
     
    972943        self::print_folders_skipped();
    973944        self::print_folders_not_found();
    974 
    975         // Disable maintenance mode before completion message
    976         One_Click_Migration::disable_maintenance_mode();
    977945
    978946        One_Click_Migration::write_to_log('Restore completed.');
     
    12101178    public static function createZipFile($filepath, $password, $presigned_urls)
    12111179    {
     1180        // Suppress PHP 8+ compatibility warnings from vendor library
     1181        $old_error_reporting = error_reporting();
     1182        error_reporting($old_error_reporting & ~E_DEPRECATED & ~E_NOTICE);
     1183       
    12121184        $zip = new ZipFile();
    12131185        $filename = OCM_PLUGIN_WRITABLE_PATH . 'db.zip';
     
    12841256          return $return;
    12851257        }
    1286 
     1258       
     1259        // Restore original error reporting
     1260        error_reporting($old_error_reporting);
    12871261    }
    12881262
    12891263    public static function initiate_folder_backup($folder_name, $presigned_urls, $password)
    12901264    {
     1265        // Suppress PHP 8+ compatibility warnings from vendor library
     1266        $old_error_reporting = error_reporting();
     1267        error_reporting($old_error_reporting & ~E_DEPRECATED & ~E_NOTICE);
     1268       
    12911269        // Initialize archive object
    12921270        $zip = new ZipFile();
     
    15391517            }
    15401518        }
     1519       
     1520        // Restore original error reporting
     1521        error_reporting($old_error_reporting);
    15411522    }
    15421523
     
    16191600
    16201601        return true;
    1621     }
    1622 
    1623     /**
    1624      * Handle restore errors and disable maintenance mode
    1625      */
    1626     private static function handle_restore_error($message)
    1627     {
    1628         One_Click_Migration::write_to_log($message);
    1629         update_option('ocm_is_stopped', true, true);
    1630         One_Click_Migration::disable_maintenance_mode();
    1631         die();
    16321602    }
    16331603
     
    18061776        $uploadFileData = get_option('ocm_upload_file');
    18071777        $isStopped = get_option('ocm_is_stopped');
    1808         $isMaintenanceMode = get_option('ocm_maintenance_mode', false);
    18091778
    18101779        if ($isStopped) { // cancel all bg process
     
    18171786                'text' => $lastLog,
    18181787                'value' => self::get_previous_log_percentage(),
    1819                 'customNotice' => self::LOG_MESSAGE_BG_PROCESS_RESTARTING_LOG,
    1820                 'maintenanceMode' => $isMaintenanceMode
     1788                'customNotice' => self::LOG_MESSAGE_BG_PROCESS_RESTARTING_LOG
    18211789            ];
    18221790        }
     
    18271795                'text' => $lastLog,
    18281796                'value' => self::get_previous_log_percentage(),
    1829                 'maintenanceMode' => $isMaintenanceMode
     1797
    18301798            ];
    18311799        }
     
    18361804                'text' => 'Process is Restarting',
    18371805                'value' => self::get_previous_log_percentage(),
    1838                 'maintenanceMode' => $isMaintenanceMode
     1806
    18391807            ];
    18401808        }
     
    18461814                'text' => $lastLog,
    18471815                'value' => self::get_previous_log_percentage(),
    1848                 'maintenanceMode' => $isMaintenanceMode
     1816
    18491817            ];
    18501818        }
     
    18531821        $default_text = array(
    18541822            'text' => 'Start a backup or a restore to see current progress here.</br></br>Entire process runs in the background, independent of your browser activity.</br> </br>If you get logged out during restore, log back in using your backup old WordPress credentials and refresh this page for progress.',
    1855             'value' => '0%',
    1856             'maintenanceMode' => $isMaintenanceMode
     1823            'value' => '0%'
    18571824        );
    18581825
     
    18671834                        'uploadFileData' => $uploadFileData,
    18681835                        'text' => $lastLog,
    1869                         'value' => $progress_item[1],
    1870                         'maintenanceMode' => $isMaintenanceMode
     1836                        'value' => $progress_item[1]
    18711837                    );
    18721838                } else {
     
    18741840                        'uploadFileData' => $uploadFileData,
    18751841                        'text' => $lastLog,
    1876                         'value' => $progress_item[1],
    1877                         'maintenanceMode' => $isMaintenanceMode
     1842                        'value' => $progress_item[1]
    18781843                    );
    18791844                }
    18801845
    18811846                if ($isStopped && $lastLog !== 'Restore completed.') {
    1882 $progress_item_text = array(
     1847                    $progress_item_text = array(
    18831848                        'isStopped' => true,
    18841849                        'text' => $lastLog,
    1885                         'value' => $progress_item[1],
    1886                         'maintenanceMode' => $isMaintenanceMode
     1850                        'value' => $progress_item[1]
    18871851                    );
    18881852                }
  • 1-click-migration/trunk/one-click-migration.php

    r3372639 r3374608  
    55 * Plugin URI: https://wordpress.org/plugins/1-click-migration/
    66 * Description: Migrate, copy, or clone your entire site with 1 click. <strong>Any host, no size limitation, no premium versions.</strong>
    7  * Version: 2.3
     7 * Version: 2.3.1
    88 * Author: 1ClickMigration
    99 * Author URI: https://1clickmigration.com/
     
    348348    {
    349349        self::delete_options();
    350         // Delete ocm_restore folder
    351         if (is_dir(WP_CONTENT_DIR . '/ocm_restore/')) {
    352             OCM_Backup::deleteDir(WP_CONTENT_DIR . '/ocm_restore/', 'Deleting ocm_restore', null);
    353         }
    354 
    355         // Clear tmp folder
    356         if (is_dir(OCM_PLUGIN_WRITABLE_PATH)) {
    357             OCM_Backup::deleteDir(OCM_PLUGIN_WRITABLE_PATH, 'Deleting TMP Folder', null);
     350       
     351        // Delete ocm_restore folder (silently - don't log errors during deactivation)
     352        try {
     353            if (is_dir(WP_CONTENT_DIR . '/ocm_restore/')) {
     354                self::delete_directory_recursive(WP_CONTENT_DIR . '/ocm_restore/');
     355            }
     356        } catch (\Exception $e) {
     357            // Silently fail during deactivation
     358        }
     359
     360        // Clear tmp folder (silently - don't log errors during deactivation)
     361        try {
     362            if (is_dir(OCM_PLUGIN_WRITABLE_PATH)) {
     363                self::delete_directory_recursive(OCM_PLUGIN_WRITABLE_PATH);
     364            }
     365        } catch (\Exception $e) {
     366            // Silently fail during deactivation
     367        }
     368       
     369        // Load the background helper class before using it
     370        if (!class_exists('OCM\OCM_BackgroundHelper')) {
     371            require_once __DIR__ . '/inc/background/class-background-helper.php';
    358372        }
    359373        OCM_BackgroundHelper::delete_all_batch_process();
     
    362376        flush_rewrite_rules();
    363377
     378    }
     379   
     380    /**
     381     * Recursively delete a directory without logging (for safe deactivation)
     382     *
     383     * @param string $dir Directory path to delete
     384     * @return bool True on success, false on failure
     385     */
     386    private static function delete_directory_recursive($dir)
     387    {
     388        if (!is_dir($dir)) {
     389            return false;
     390        }
     391       
     392        $items = @scandir($dir);
     393        if ($items === false) {
     394            return false;
     395        }
     396       
     397        foreach ($items as $item) {
     398            if ($item === '.' || $item === '..') {
     399                continue;
     400            }
     401           
     402            $path = $dir . '/' . $item;
     403           
     404            if (is_dir($path)) {
     405                self::delete_directory_recursive($path);
     406            } else {
     407                @unlink($path);
     408            }
     409        }
     410       
     411        return @rmdir($dir);
    364412    }
    365413
     
    494542    public static function cancel_all_process()
    495543    {
     544        // Load the background helper class before using it
     545        if (!class_exists('OCM\OCM_BackgroundHelper')) {
     546            require_once __DIR__ . '/inc/background/class-background-helper.php';
     547        }
    496548        OCM_BackgroundHelper::delete_all_batch_process();
    497         self::$process_backup_single->cancel_all_process();
    498         self::$process_restore_single->cancel_all_process();
     549       
     550        // Only call cancel methods if the process objects exist
     551        if (self::$process_backup_single) {
     552            self::$process_backup_single->cancel_all_process();
     553        }
     554        if (self::$process_restore_single) {
     555            self::$process_restore_single->cancel_all_process();
     556        }
    499557
    500558    }
     
    520578        if (is_dir(OCM_PLUGIN_WRITABLE_PATH)) {
    521579            OCM_Backup::deleteDir(OCM_PLUGIN_WRITABLE_PATH, 'Deleting TMP Folder', null);
     580        }
     581       
     582        // Load the background helper class before using it
     583        if (!class_exists('OCM\OCM_BackgroundHelper')) {
     584            require_once __DIR__ . '/inc/background/class-background-helper.php';
    522585        }
    523586        OCM_BackgroundHelper::delete_all_batch_process();
     
    630693    public static function disable_maintenance_mode()
    631694    {
    632         // Remove our custom maintenance mode option
    633         delete_option('ocm_maintenance_mode');
    634        
    635         // Also remove any .maintenance file that might exist
    636695        $maintenance_file = ABSPATH . '.maintenance';
     696       
    637697        if (file_exists($maintenance_file)) {
    638             unlink($maintenance_file);
    639         }
    640        
    641         One_Click_Migration::write_to_log('Maintenance mode disabled');
    642         return true;
     698            if (unlink($maintenance_file)) {
     699                One_Click_Migration::write_to_log('Maintenance mode disabled');
     700                return true;
     701            } else {
     702                One_Click_Migration::write_to_log('Error: Failed to disable maintenance mode');
     703                return false;
     704            }
     705        }
     706       
     707        return true; // Already disabled
    643708    }
    644709}
  • 1-click-migration/trunk/readme.txt

    r3372639 r3374608  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 2.3
     7Stable tag: 2.3.1
    88Author URI: https://1clickmigration.com
    99License: GPLv3 or later
     
    9090 
    9191== Changelog ==
     92= 2.3.1 =
     93* Fixed blank white screen issue when deactivating plugin
     94* Fixed endpoint_failure error on first backup attempt - added retry logic for presigned URL generation
     95* Improved deactivation cleanup process to prevent database errors
     96* Enhanced error handling during plugin deactivation
     97
     98= 2.3 =
     99* Stability improvements
     100
    92101= 2.2 =
    93102* CSRF fix & Updates
Note: See TracChangeset for help on using the changeset viewer.