Plugin Directory

Changeset 3312938


Ignore:
Timestamp:
06/17/2025 06:56:19 AM (10 months ago)
Author:
watchful
Message:

v4.7.8

Location:
xcloner-backup-and-restore/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • xcloner-backup-and-restore/trunk/CHANGELOG.txt

    r3195000 r3312938  
     1= 4.7.8 =
     2* https://github.com/watchfulli/XCloner-Wordpress/issues/322
     3* https://github.com/watchfulli/XCloner-Wordpress/issues/329
     4
     5= 4.7.7 =
     6* Update "tested up to" version
     7
    18= 4.7.6 =
    29* Update "tested up to" version
  • xcloner-backup-and-restore/trunk/admin/partials/xcloner_restore_page.php

    r2820379 r3312938  
    238238                                           data-tooltip="<?php echo __('Restore the database-sql.sql mysql backup from the xcloner-xxxxx/ folder', 'xcloner-backup-and-restore') ?>">
    239239                                        <input class="with-gap" name="filter_files" type="radio" id="filter_files_database"
    240                                                value="/^xcloner-(.*)\/(.*)\.sql/"/>
     240                                               value="#^xcloner-(.*)/(.*).sql#"/>
    241241                                        <span>
    242242                                        <?php echo __("Only Database Backup", "xcloner-backup-and-restore") ?>
  • xcloner-backup-and-restore/trunk/lib/Xcloner_Restore.php

    r2843536 r3312938  
    217217
    218218        $mysqli = $this->xcloner_container->get_xcloner_database();
     219        $this->set_foreign_key_checks($mysqli, false);
    219220
    220221        $line_count = 0;
     
    246247            }
    247248
    248             //exclude usermeta info for local restores to fix potential session logout
    249             if (strpos($line, "_usermeta`") !== false) {
    250                 $line = str_replace("_usermeta`", "_usermeta2`", $line);
    251             }
     249            $prefix = $mysqli->prefix;
     250            $tables_to_update = ['usermeta', 'users', 'options'];
     251
     252            foreach ($tables_to_update as $table) {
     253                $search = "`$prefix$table`";
     254                $replace = "`$prefix{$table}_new`";
     255
     256                if (strpos($line, $search) !== false) {
     257                    $line = str_replace($search, $replace, $line);
     258                }
     259            }
     260
     261            if (stripos($line, 'INSERT INTO') !== false) {
     262                $line = preg_replace('/INSERT\s+INTO/i', 'INSERT IGNORE INTO', $line);
     263            }
    252264
    253265            $query .= $line;
     
    261273            }
    262274
    263             if (!$mysqli->query($query) && !stristr($mysqli->error, "Duplicate entry")) {
     275            if ($mysqli->query($query) === false && !stristr($mysqli->error, "Duplicate entry")) {
    264276                //$return['error_line'] = $line_count;
    265277                $return['start'] = ftell($fp) - strlen($line);
     
    288300        } else {
    289301            $this->logger->info('Mysql Import Done.');
     302            $this->set_foreign_key_checks($mysqli, true);
    290303        }
    291304
     
    318331
    319332        $wpdb->select($wpdb->dbname);
    320 
    321333        $wpdb->hide_errors();
    322         if ($result = $wpdb->get_var("SELECT count(*) FROM " . $wpdb->prefix . "usermeta2")) {
    323             if ($result > 0) {
    324                 $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "usermeta_backup");
    325                 $wpdb->query("ALTER TABLE " . $wpdb->prefix . "usermeta RENAME TO " . $wpdb->prefix . "usermeta_backup");
    326                 $wpdb->query("ALTER TABLE " . $wpdb->prefix . "usermeta2 RENAME TO " . $wpdb->prefix . "usermeta");
    327             }
    328         }
     334
     335        foreach ( [ 'usermeta', 'users', 'options' ] as $table ) {
     336            $this->replace_table_with_new_version( $wpdb, $table );
     337        }
    329338
    330339        $return = "Restore Process Finished.";
    331340        $this->send_response(200, $return);
    332341    }
     342
     343    private function replace_table_with_new_version( $mysqli, $table_name ) {
     344        $prefix = $mysqli->prefix;
     345
     346        $count = $mysqli->get_var( "SELECT count(*) FROM `$prefix{$table_name}_new`" );
     347        if ( $count <= 0 ) {
     348            return;
     349        }
     350
     351        $mysqli->query( "DROP TABLE IF EXISTS `$prefix{$table_name}_backup`" );
     352        $mysqli->query( "ALTER TABLE `$prefix$table_name` RENAME TO `$prefix{$table_name}_backup`" );
     353        $mysqli->query( "ALTER TABLE `$prefix{$table_name}_new` RENAME TO `$prefix$table_name`" );
     354    }
    333355
    334356    /**
     
    507529        $include_filter_files = $this->xcloner_sanitization->sanitize_input_as_string($_POST['filter_files']);
    508530        $exclude_filter_files = "";
    509         $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
    510         $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
    511         $return['processed'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['processed']);
     531        $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start'] ?? 0);
     532        $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['part'] ?? 0);
     533        $return['processed'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['processed'] ?? 0);
    512534        $this->target_adapter = new Local($this->site_path, LOCK_EX, 'SKIP_LINKS');
    513535        $this->target_filesystem = new Filesystem($this->target_adapter, new Config([
     
    778800        die(json_encode($return));
    779801    }
     802
     803    private function set_foreign_key_checks( Xcloner_Database $mysqli, bool $enable ) {
     804        $status = (int) $enable;
     805        $mysqli->query( "SET FOREIGN_KEY_CHECKS=$status;" );
     806    }
    780807}
  • xcloner-backup-and-restore/trunk/vendor/autoload.php

    r3118643 r3312938  
    1818        }
    1919    }
    20     trigger_error(
    21         $err,
    22         E_USER_ERROR
    23     );
     20    throw new RuntimeException($err);
    2421}
    2522
  • xcloner-backup-and-restore/trunk/vendor/composer/InstalledVersions.php

    r3118643 r3312938  
    3131{
    3232    /**
     33     * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
     34     * @internal
     35     */
     36    private static $selfDir = null;
     37
     38    /**
    3339     * @var mixed[]|null
    3440     * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
    3541     */
    3642    private static $installed;
     43
     44    /**
     45     * @var bool
     46     */
     47    private static $installedIsLocalDir;
    3748
    3849    /**
     
    313324        self::$installed = $data;
    314325        self::$installedByVendor = array();
     326
     327        // when using reload, we disable the duplicate protection to ensure that self::$installed data is
     328        // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
     329        // so we have to assume it does not, and that may result in duplicate data being returned when listing
     330        // all installed packages for example
     331        self::$installedIsLocalDir = false;
     332    }
     333
     334    /**
     335     * @return string
     336     */
     337    private static function getSelfDir()
     338    {
     339        if (self::$selfDir === null) {
     340            self::$selfDir = strtr(__DIR__, '\\', '/');
     341        }
     342
     343        return self::$selfDir;
    315344    }
    316345
     
    326355
    327356        $installed = array();
     357        $copiedLocalDir = false;
    328358
    329359        if (self::$canGetVendors) {
     360            $selfDir = self::getSelfDir();
    330361            foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
     362                $vendorDir = strtr($vendorDir, '\\', '/');
    331363                if (isset(self::$installedByVendor[$vendorDir])) {
    332364                    $installed[] = self::$installedByVendor[$vendorDir];
     
    334366                    /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
    335367                    $required = require $vendorDir.'/composer/installed.php';
    336                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
    337                     if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
    338                         self::$installed = $installed[count($installed) - 1];
     368                    self::$installedByVendor[$vendorDir] = $required;
     369                    $installed[] = $required;
     370                    if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
     371                        self::$installed = $required;
     372                        self::$installedIsLocalDir = true;
    339373                    }
     374                }
     375                if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
     376                    $copiedLocalDir = true;
    340377                }
    341378            }
     
    354391        }
    355392
    356         if (self::$installed !== array()) {
     393        if (self::$installed !== array() && !$copiedLocalDir) {
    357394            $installed[] = self::$installed;
    358395        }
  • xcloner-backup-and-restore/trunk/vendor/composer/installed.php

    r3195000 r3312938  
    55    'root' => array(
    66        'name' => 'watchfulli/xcloner-wordpress',
    7         'pretty_version' => 'v4.7.7',
    8         'version' => '4.7.7.0',
    9         'reference' => '4636a06b674a88dab301be6fd7f9aca7e20d7cd3',
     7        'pretty_version' => 'v4.7.8',
     8        'version' => '4.7.8.0',
     9        'reference' => 'a3f1c4d1953012d7c89400e70a50c19f33df0858',
    1010        'type' => 'library',
    1111        'install_path' => __DIR__ . '/../../',
     
    498498        ),
    499499        'watchfulli/xcloner-wordpress' => array(
    500             'pretty_version' => 'v4.7.7',
    501             'version' => '4.7.7.0',
    502             'reference' => '4636a06b674a88dab301be6fd7f9aca7e20d7cd3',
     500            'pretty_version' => 'v4.7.8',
     501            'version' => '4.7.8.0',
     502            'reference' => 'a3f1c4d1953012d7c89400e70a50c19f33df0858',
    503503            'type' => 'library',
    504504            'install_path' => __DIR__ . '/../../',
  • xcloner-backup-and-restore/trunk/xcloner.php

    r3195000 r3312938  
    1616 * Plugin URI: https://xcloner.com/
    1717 * Description:  XCloner is a tool that will help you manage your website backups, generate/restore/move so your website will be always secured! With XCloner you will be able to clone your site to any other location with just a few clicks, as well as transfer the backup archives to remote FTP, SFTP, DropBox, Amazon S3, Google Drive, WebDAV, Backblaze, Azure accounts.
    18  * Version: 4.7.7
     18 * Version: 4.7.8
    1919 * Author: watchful
    2020 * Author URI: https://watchful.net/
Note: See TracChangeset for help on using the changeset viewer.