Skip to content

Commit

Permalink
Deploying version 2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedTheGeek committed Aug 12, 2022
1 parent d296ccf commit b3ba13c
Show file tree
Hide file tree
Showing 44 changed files with 1,277 additions and 831 deletions.
3 changes: 3 additions & 0 deletions class/Common/Cli/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ function migrate_table($args = false)
*/
function finalize_ajax($response, $post_data)
{
if (is_wp_error($response)) {
return $response;
}
// don't send redundant POST variables
$args = $this->http_helper->filter_post_elements($post_data, array('action', 'migration_state_id', 'prefix', 'tables', 'profileID', 'profileType'));
$_POST = $args;
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Cli/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function export($args, $assoc_args)
{

$assoc_args['action'] = 'savefile';
$assoc_args['export_dest'] = trim($args[0]);
$assoc_args['export_dest'] = sanitize_file_name($args[0]);

if (empty($assoc_args['export_dest'])) {
\WP_CLI::error(Cli::cleanup_message(__('You must provide a destination filename.', 'wp-migrate-db-cli')));
Expand Down
10 changes: 10 additions & 0 deletions class/Common/Compatibility/Compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public function __construct() {
$this->muplugin_class_dir = plugin_dir_path( __FILE__ );
$this->muplugin_dir = ( defined( 'WPMU_PLUGIN_DIR' ) && defined( 'WPMU_PLUGIN_URL' ) ) ? WPMU_PLUGIN_DIR : trailingslashit( WP_CONTENT_DIR ) . 'mu-plugins';


}

/**
* Registers action and filter hooks
*
* @return void
**/
public function register()
{
add_action( 'admin_init', array( $this, 'wpmdbc_tgmpa_compatibility' ), 1 );
add_filter( 'option_active_plugins', array( $this, 'wpmdbc_include_plugins' ) );
add_filter( 'site_option_active_sitewide_plugins', array( $this, 'wpmdbc_include_site_plugins' ) );
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Compatibility/CompatibilityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __construct(
$this->util = $util;

//Version of the compatibility plugin, to force an update of the MU plugin, increment this value
$this->compatibility_plugin_version = '1.2';
$this->compatibility_plugin_version = '1.3';

$this->mu_plugin_dir = $this->props->mu_plugin_dir;
$this->mu_plugin_source = $this->props->mu_plugin_source;
Expand Down
35 changes: 33 additions & 2 deletions class/Common/Error/ErrorLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,30 @@ function log_error($wpmdb_error, $additional_error_var = false)

$error_header = "********************************************\n****** Log date: " . date('Y/m/d H:i:s') . " ******\n********************************************\n\n";
$error = $error_header;
if ($this->get_migration_id($state_data)) {
$error .= 'Migration ID: ' . $this->get_migration_id($state_data) . "\n";
}
if (isset($state_data['intent'])) {
$error .= 'Intent: ' . $state_data['intent'] . "\n";
}
if (isset($state_data['stages'])) {
$error .= 'Stages: ' . implode(' | ', json_decode($state_data['stages'], true) ). "\n";
}
if (isset($state_data['action'])) {
$error .= 'Action: ' . $state_data['action'] . "\n";
}
if (isset($state_data['local']) && isset($state_data['local']['site_url'])) {
$error .= 'Local: ' . $state_data['site_details']['local']['site_url'] . "\n";
}
if (isset($state_data['remote']) && isset($state_data['remote']['site_url'])) {
$error .= 'Remote: ' . $state_data['site_details']['remote']['site_url'] . "\n\n";
$error .= 'Remote: ' . $state_data['site_details']['remote']['site_url'] . "\n";
}
if (isset($GLOBALS['wpmdb_meta']) && isset($GLOBALS['wpmdb_meta']['wp-migrate-db-pro'])) {
$error .= 'WP Migrate Version: ' .$GLOBALS['wpmdb_meta']['wp-migrate-db-pro']['version'] . "\n\n";
}
$error .= 'WPMDB Error: ' . $wpmdb_error . "\n\n";
$error .= 'Error: ' . $wpmdb_error . "\n";



if (!empty($this->props->attempting_to_connect_to)) {
$ip = $this->get_remote_ip($this->props->attempting_to_connect_to);
Expand Down Expand Up @@ -154,6 +165,26 @@ function log_error($wpmdb_error, $additional_error_var = false)
update_site_option('wpmdb_error_log', $this->error_log);
}

/**
* Get Migration ID
*
* @param array $state_data Description
* @return mixed string|bool
**/
public function get_migration_id($state_data)
{
if (!isset($state_data['form_data'])) {
return false;
}
$form_data = json_decode($state_data['form_data']);
if (property_exists($form_data, 'current_migration')
&& property_exists($form_data->current_migration, 'migration_id')
) {
return $form_data->current_migration->migration_id;
}
return false;
}

function get_remote_ip($url)
{
$parsed_url = Util::parse_url($url);
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ function close($fp)

public function format_backup_name($file_name)
{
$new_name = preg_replace('/-\w{5}.sql/', '.sql${1}', $file_name);
$new_name = preg_replace('/-\w{5}.sql/', '.sql', $file_name);

return $new_name;
}
Expand Down
12 changes: 11 additions & 1 deletion class/Common/Http/RemotePost.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ public function post($url, $data, $scope, $args = [], $expecting_serial = false)
);

$args['method'] = 'POST';

$remote_cookie = Persistence::getRemoteWPECookie();
if (false !== $remote_cookie) {
$cookies = [];
$cookie_args = [
'name' => 'wpe-auth',
'value' => $remote_cookie,
];
$cookie = new \WP_Http_Cookie($cookie_args);
$cookies[] = $cookie;
$args['cookies'] = $cookies;
}
if (!isset($args['body'])) {
$args['body'] = $this->array_to_multipart($data);
}
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Migration/FinalizeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function ajax_finalize_migration()
} else {
$return = $this->finalize_migration($state_data);
}

do_action('wpmdb_after_finalize_migration');
$result = $this->http->end_ajax($return);

return $result;
Expand Down
30 changes: 30 additions & 0 deletions class/Common/MigrationPersistence/Persistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,36 @@ public static function storeRemoteResponse($response)
return update_site_option('wpmdb_remote_response', $response);
}

/**
* Stores value of WPE auth cookie stored in site options
* @param string $cookie
* @return bool
**/
public static function storeRemoteWPECookie($cookie)
{
return update_site_option('wpmdb_wpe_remote_cookie', $cookie);
}

/**
* Get value of WPE auth cookie stored in site options
*
* @return bool
**/
public static function getRemoteWPECookie()
{
return get_site_option('wpmdb_wpe_remote_cookie');
}

/**
* Remove WPE auth cookie stored in site options
*
* @return bool
**/
public static function removeRemoteWPECookie()
{
return delete_site_option('wpmdb_wpe_remote_cookie');
}

public static function getPostData($fields)
{
$state_data = get_site_option('wpmdb_migration_state');
Expand Down
22 changes: 0 additions & 22 deletions class/Common/Profile/ProfileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,28 +642,6 @@ function ($item) use (&$all_tables) {
return $filtered_tables;
}

/**
* @param $saved_profiles
* @param $state_data
*
* @return array|\WP_Error
*/
public function decode_profile_data($the_profile)
{
if (empty($saved_profiles) || !\is_array($saved_profiles)) {
return new \WP_Error('wpmdb_profile_not_found', __('Profile not found.', 'wp-migrate-db'));
}


$parsed_profile = json_decode($the_profile['value'], true);

if (!$parsed_profile) {
return new \WP_Error('wpmdb_profile_invalid_json', __('Profile saved as invalid JSON.', 'wp-migrate-db'));
}

return $parsed_profile;
}

/**
* @param $option_key
* @param $profile_id
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Properties/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Properties
public $temp_prefix = '_mig_';
public $transient_timeout;
public $transient_retry_timeout;
public $dbrains_api_status_url = 'http://s3.amazonaws.com/cdn.deliciousbrains.com/status.json';
public $dbrains_api_status_url = 'https://s3.amazonaws.com/cdn.deliciousbrains.com/status.json';
public $multipart_boundary = 'bWH4JVmYCnf6GfXacrcc';
public $invalid_content_verification_error;
public $util;
Expand Down
13 changes: 9 additions & 4 deletions class/Common/Replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,14 +852,19 @@ protected function json_replaces($prefix)
* @throws \DI\NotFoundException
*/
public function validate_regex_pattern() {
$_POST = $this->http_helper->convert_json_body_to_post();

$_POST = $this->http_helper->convert_json_body_to_post();
if (isset($_POST['pattern'])) {
$pattern = Util::safe_wp_unslash($_POST['pattern']);
if (Util::is_regex_pattern_valid( $pattern ) === false) {
return $this->http->end_ajax(false);
}
}
$key_rules = array(
'pattern' => 'string',
'pattern' => 'regex',
);

$state_data = $this->migration_state_manager->set_post_data( $key_rules );
return $this->http->end_ajax( Util::is_regex_pattern_valid( $state_data['pattern'] ) );
return $this->http->end_ajax(isset($state_data['pattern']) === true);
}

public function register_rest_routes() {
Expand Down
10 changes: 8 additions & 2 deletions class/Common/Sanitize.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DeliciousBrains\WPMDB\Common;

use DeliciousBrains\WPMDB\Common\Exceptions\SanitizationFailureException;
use DeliciousBrains\WPMDB\Common\Util\Util;

/**
*
Expand Down Expand Up @@ -96,6 +97,11 @@ private static function _sanitize_data($data, $key_rules, $context, $recursion_l
throw new SanitizationFailureException(self::create_error_string('a string', $context, $data, self::$field_key));
}
$data = filter_var($data, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
} elseif ('regex' === $key_rules) {
if (Util::is_regex_pattern_valid($data) === false) {
throw new SanitizationFailureException(self::create_error_string('a regex string', $context, $data, self::$field_key));
}
$data = $data;
} elseif ('key' === $key_rules) {
$key_name = sanitize_key($data);
if ($key_name !== $data) {
Expand All @@ -114,13 +120,13 @@ private static function _sanitize_data($data, $key_rules, $context, $recursion_l
}
// @TODO - Needs sanitizing
} elseif ('json_array' === $key_rules) {
if (!is_string($data) || !Util\Util::is_json($data)) {
if (!is_string($data) || !Util::is_json($data)) {
throw new SanitizationFailureException(self::create_error_string('JSON data', $context, $data, self::$field_key));
}
// @TODO - Needs sanitizing
$data = json_decode($data, true);
} elseif ('json' === $key_rules) {
if (!is_string($data) || !Util\Util::is_json($data)) {
if (!is_string($data) || !Util::is_json($data)) {
throw new SanitizationFailureException(self::create_error_string('JSON data', $context, $data, self::$field_key));
}
// @TODO - Needs sanitizing
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ public static function settings_page_link()
}

public static function is_regex_pattern_valid($pattern) {
return @preg_match($pattern, null) !== false;
return @preg_match($pattern, '') !== false;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions compatibility/wp-migrate-db-pro-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://deliciousbrains.com/wp-migrate-db-pro/
Description: Prevents 3rd party plugins from being loaded during WP Migrate DB specific operations
Author: Delicious Brains
Version: 1.2
Version: 1.3
Author URI: http://deliciousbrains.com
*/

Expand Down Expand Up @@ -41,5 +41,6 @@
}

if ( class_exists( $compat_class_name ) ) {
new $compat_class_name;
$compatibility = new $compat_class_name;
$compatibility->register();
}
5 changes: 3 additions & 2 deletions compatibility/wp-migrate-db-pro-compatibility.php-e
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Plugin Name: ##PLUGIN_NAME_PLACEHOLDER##
Plugin URI: http://deliciousbrains.com/wp-migrate-db-pro/
Description: Prevents 3rd party plugins from being loaded during WP Migrate DB specific operations
Author: Delicious Brains
Version: 1.2
Version: 1.3
Author URI: http://deliciousbrains.com
*/

Expand Down Expand Up @@ -41,5 +41,6 @@ if ( file_exists( $wpmdbpro_compatibility_class ) ) {
}

if ( class_exists( $compat_class_name ) ) {
new $compat_class_name;
$compatibility = new $compat_class_name;
$compatibility->register();
}
18 changes: 9 additions & 9 deletions frontend/build-free/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"styles.css": "./static/css/styles.d3d9a86d.chunk.css",
"styles.js": "./static/js/styles.cbdd8474eae8.chunk.js",
"main.js": "./static/js/main.968a88e78637.chunk.js",
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.a0b932e58c8b.js",
"static/js/3.c33b00d7e660.chunk.js": "./static/js/3.c33b00d7e660.chunk.js",
"static/js/4.d8771a4b47fa.chunk.js": "./static/js/4.d8771a4b47fa.chunk.js",
"static/js/5.4a0618460681.chunk.js": "./static/js/5.4a0618460681.chunk.js",
"static/js/6.d8817d92c25b.chunk.js": "./static/js/6.d8817d92c25b.chunk.js",
"static/js/7.ead30606bc85.chunk.js": "./static/js/7.ead30606bc85.chunk.js",
"styles.css": "./static/css/styles.1afaa94d.chunk.css",
"styles.js": "./static/js/styles.88b6922861d7.chunk.js",
"main.js": "./static/js/main.9e97ea926f20.chunk.js",
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.c4db933a4fa9.js",
"static/js/3.e33bc7b2cd87.chunk.js": "./static/js/3.e33bc7b2cd87.chunk.js",
"static/js/4.cffabdd1786b.chunk.js": "./static/js/4.cffabdd1786b.chunk.js",
"static/js/5.157ac3fb36a3.chunk.js": "./static/js/5.157ac3fb36a3.chunk.js",
"static/js/6.f84d190c9092.chunk.js": "./static/js/6.f84d190c9092.chunk.js",
"static/js/7.7454efd95b93.chunk.js": "./static/js/7.7454efd95b93.chunk.js",
"static/media/action-backup-database.ab9022dd.svg": "./static/media/action-backup-database.ab9022dd.svg",
"static/media/action-export-database.617087b6.svg": "./static/media/action-export-database.617087b6.svg",
"static/media/action-import-database.03003cd8.svg": "./static/media/action-import-database.03003cd8.svg",
Expand Down
1 change: 1 addition & 0 deletions frontend/build-free/static/css/styles.1afaa94d.chunk.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion frontend/build-free/static/css/styles.d3d9a86d.chunk.css

This file was deleted.

Loading

0 comments on commit b3ba13c

Please sign in to comment.