Skip to content

Commit

Permalink
Deploying version 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmjones committed Oct 4, 2024
1 parent f0bd63f commit 3ec1276
Show file tree
Hide file tree
Showing 119 changed files with 852 additions and 2,841 deletions.
2 changes: 1 addition & 1 deletion class/Common/Migration/MigrationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function ajax_migrate_table()
// need to split this up into a chunk and row_tracker
// only strip the last new line if it exists
$row_information = false !== strpos($response, "\n") ? trim(substr(strrchr($response, "\n"), 1)) : trim($response);
$row_information = explode(',', $row_information);
$row_information = explode('##MDB_SEPARATOR##', $row_information);
$chunk = substr($response, 0, strrpos($response, ";\n") + 1);

if (!empty($chunk)) {
Expand Down
26 changes: 21 additions & 5 deletions class/Common/Replace.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,12 +769,28 @@ protected function should_do_reference_check($table_prefix)
if ( $this->table_is('options', $table_prefix) && 'option_value' === $this->get_column()) {
return true;
}
if ( $table_prefix . 'duplicator_packages' === $this->get_table() && 'package' === $this->get_column() ) {
return true;
}
if ( $table_prefix . 'aiowps_audit_log' === $this->get_table() && 'stacktrace' === $this->get_column() ) {
return true;
$table_column_for_check = [
[
'table' => $table_prefix . 'duplicator_packages',
'column' => 'package'
],
[
'table' => $table_prefix . 'aiowps_audit_log',
'column' => 'stacktrace'
]
];
$table_column_for_check = apply_filters('wpmdb_check_table_column_for_reference', $table_column_for_check);
foreach($table_column_for_check as $table_column ) {
if (
array_key_exists('table', $table_column)
&& $table_column['table'] === $this->get_table()
&& array_key_exists('column', $table_column)
&& $table_column['column'] === $this->get_column()
) {
return true;
}
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion class/Common/Sql/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ function transfer_chunk($fp, $state_data)
}

if ($state_data['intent'] === 'pull') {
$str = $this->row_tracker . ',' . json_encode($this->primary_keys);
$str = $this->row_tracker . '##MDB_SEPARATOR##' . json_encode($this->primary_keys);
$result = $this->http->end_ajax($str, '', true);

return $result;
Expand Down
1 change: 1 addition & 0 deletions class/Common/Sql/TableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function format_dump_name($dump_name)
* @param string $scope Optional type of table to match against, default is 'table'.
* @param string $new_prefix Optional new prefix already added to $given_table.
* @param int $blog_id Optional Only used with 'blog' scope to test against a specific subsite's tables other than current for $wpdb.
* @param string $source_prefix Optional prefix from source site already added to $given_table.
*
* @return boolean
*/
Expand Down
244 changes: 244 additions & 0 deletions class/Free/PluginUpdater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
<?php
/**
* The PluginUpdater class which can be used to pull plugin updates from a new location.
* @package wp-migrate-db
*/

namespace DeliciousBrains\WPMDB\Free;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

use stdClass;

/**
* The PluginUpdater class which can be used to pull plugin updates from a new location.
*/
class PluginUpdater {
/**
* The URL where the api is located.
* @var ApiUrl
*/
private $api_url;

/**
* The amount of time to wait before checking for new updates.
* @var CacheTime
*/
private $cache_time;

/**
* These properties are passed in when instantiating to identify the plugin and it's update location.
* @var Properties
*/
private $properties;

/**
* Get the class constructed.
*
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
*/
public function __construct( $properties ) {
if (
empty( $properties['plugin_slug'] ) ||
empty( $properties['plugin_basename'] )
) {
error_log( 'WPE Secure Plugin Updater received a malformed request.' );
return;
}

$this->api_url = 'https://wpe-plugin-updates.wpengine.com/';

$this->cache_time = time() + HOUR_IN_SECONDS * 5;

$this->properties = $this->get_full_plugin_properties( $properties, $this->api_url );

if ( ! $this->properties ) {
return;
}

$this->register();
}

/**
* Get the full plugin properties, including the directory name, version, basename, and add a transient name.
*
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
* @param ApiUrl $api_url The URL where the api is located.
*/
public function get_full_plugin_properties( $properties, $api_url ) {
$plugins = \get_plugins();

// Scan through all plugins installed and find the one which matches this one in question.
foreach ( $plugins as $plugin_basename => $plugin_data ) {
// Match using the passed-in plugin's basename.
if ( $plugin_basename === $properties['plugin_basename'] ) {
// Add the values we need to the properties.
$properties['plugin_dirname'] = dirname( $plugin_basename );
$properties['plugin_version'] = $plugin_data['Version'];
$properties['plugin_update_transient_name'] = 'wpesu-plugin-' . sanitize_title( $properties['plugin_dirname'] );
$properties['plugin_update_transient_exp_name'] = 'wpesu-plugin-' . sanitize_title( $properties['plugin_dirname'] ) . '-expiry';
$properties['plugin_manifest_url'] = trailingslashit( $api_url ) . trailingslashit( $properties['plugin_slug'] ) . 'info.json';

return $properties;
}
}

// No matching plugin was found installed.
return null;
}

/**
* Register hooks.
*
* @return void
*/
public function register() {
add_filter( 'plugins_api', array( $this, 'filter_plugin_update_info' ), 20, 3 );
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'filter_plugin_update_transient' ) );
}

/**
* Filter the plugin update transient to take over update notifications.
*
* @param object $transient The site_transient_update_plugins transient.
*
* @handles site_transient_update_plugins
* @return object
*/
public function filter_plugin_update_transient( $transient ) {
// No update object exists. Return early.
if ( empty( $transient ) ) {
return $transient;
}

$result = $this->fetch_plugin_info();

if ( false === $result ) {
return $transient;
}

if ( version_compare( $this->properties['plugin_version'], $result->version, '<' ) ) {
$res = $this->parse_plugin_info( $result );
$transient->response[ $res->plugin ] = $res;
$transient->checked[ $res->plugin ] = $result->version;
}

return $transient;
}

/**
* Filters the plugin update information.
*
* @param object $res The response to be modified for the plugin in question.
* @param string $action The action in question.
* @param object $args The arguments for the plugin in question.
*
* @handles plugins_api
* @return object
*/
public function filter_plugin_update_info( $res, $action, $args ) {
// Do nothing if this is not about getting plugin information.
if ( 'plugin_information' !== $action ) {
return $res;
}

// Do nothing if it is not our plugin.
if ( $this->properties['plugin_dirname'] !== $args->slug ) {
return $res;
}

$result = $this->fetch_plugin_info();

// Do nothing if we don't get the correct response from the server.
if ( false === $result ) {
return $res;
}

return $this->parse_plugin_info( $result );
}

/**
* Fetches the plugin update object from the WP Product Info API.
*
* @return object|false
*/
private function fetch_plugin_info() {
// Fetch cache first.
$expiry = get_option( $this->properties['plugin_update_transient_exp_name'], 0 );
$response = get_option( $this->properties['plugin_update_transient_name'] );

if ( empty( $expiry ) || time() > $expiry || empty( $response ) ) {
$response = wp_remote_get(
$this->properties['plugin_manifest_url'],
array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json',
),
)
);

if (
is_wp_error( $response ) ||
200 !== wp_remote_retrieve_response_code( $response ) ||
empty( wp_remote_retrieve_body( $response ) )
) {
return false;
}

$response = wp_remote_retrieve_body( $response );

// Cache the response.
update_option( $this->properties['plugin_update_transient_exp_name'], $this->cache_time, false );
update_option( $this->properties['plugin_update_transient_name'], $response, false );
}

$decoded_response = json_decode( $response );

if ( json_last_error() !== JSON_ERROR_NONE ) {
return false;
}

return $decoded_response;
}

/**
* Parses the product info response into an object that WordPress would be able to understand.
*
* @param object $response The response object.
*
* @return stdClass
*/
private function parse_plugin_info( $response ) {

global $wp_version;

$res = new stdClass();
$res->name = $response->name;
$res->slug = $response->slug;
$res->version = $response->version;
$res->requires = $response->requires;
$res->download_link = $response->download_link;
$res->trunk = $response->download_link;
$res->new_version = $response->version;
$res->plugin = $this->properties['plugin_basename'];
$res->package = $response->download_link;

// Plugin information modal and core update table use a strict version comparison, which is weird.
// If we're genuinely not compatible with the point release, use our WP tested up to version.
// otherwise use exact same version as WP to avoid false positive.
$res->tested = 1 === version_compare( substr( $wp_version, 0, 3 ), $response->tested )
? $response->tested
: $wp_version;

$res->sections = array(
'description' => $response->sections->description,
'changelog' => $response->sections->changelog,
);

return $res;
}
}
28 changes: 14 additions & 14 deletions frontend/build-free/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"main.js": "./static/js/main.34c987d7aaaa.js",
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.2e36fba1b35e.js",
"static/js/879.a33252bbf8ac.chunk.js": "./static/js/879.a33252bbf8ac.chunk.js",
"static/js/897.d633170df3fa.chunk.js": "./static/js/897.d633170df3fa.chunk.js",
"static/js/613.7f5d74d1cf11.chunk.js": "./static/js/613.7f5d74d1cf11.chunk.js",
"static/js/513.f8a4a9bce00e.chunk.js": "./static/js/513.f8a4a9bce00e.chunk.js",
"static/js/406.f7351d7a08c9.chunk.js": "./static/js/406.f7351d7a08c9.chunk.js",
"static/js/537.b4fd8a6d5c2b.chunk.js": "./static/js/537.b4fd8a6d5c2b.chunk.js",
"static/js/605.b86b7a09a985.chunk.js": "./static/js/605.b86b7a09a985.chunk.js",
"styles.css": "./static/css/styles.115205e7.css",
"styles.js": "./static/js/styles.5894c30f8136.js",
"static/js/634.aadc01a62e9d.js": "./static/js/634.aadc01a62e9d.js",
"static/js/358.abfefc366410.chunk.js": "./static/js/358.abfefc366410.chunk.js",
"static/js/135.b3d3c2251903.chunk.js": "./static/js/135.b3d3c2251903.chunk.js",
"main.js": "./static/js/main.403d4d6fe1d8.js",
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.23f4ea227134.js",
"static/js/800.e69dbe829c57.chunk.js": "./static/js/800.e69dbe829c57.chunk.js",
"static/js/359.8631588d52dc.chunk.js": "./static/js/359.8631588d52dc.chunk.js",
"static/js/481.adbbff83ff0c.chunk.js": "./static/js/481.adbbff83ff0c.chunk.js",
"static/js/56.109cbdac7eb4.chunk.js": "./static/js/56.109cbdac7eb4.chunk.js",
"static/js/203.cb0dadc2e016.chunk.js": "./static/js/203.cb0dadc2e016.chunk.js",
"static/js/85.8a8af69d7986.chunk.js": "./static/js/85.8a8af69d7986.chunk.js",
"static/js/384.d12a10c3ebbb.chunk.js": "./static/js/384.d12a10c3ebbb.chunk.js",
"styles.css": "./static/css/styles.513ba96d.css",
"styles.js": "./static/js/styles.7699beeb2cf2.js",
"static/js/652.c7184786a47f.js": "./static/js/652.c7184786a47f.js",
"static/js/898.d64597f6c89a.chunk.js": "./static/js/898.d64597f6c89a.chunk.js",
"static/js/970.185a31a710b6.chunk.js": "./static/js/970.185a31a710b6.chunk.js",
"static/media/wp-migrate-2-6-0.png": "./static/media/wp-migrate-2-6-0.8d26599e.png",
"static/media/testimonial-avatar.png": "./static/media/testimonial-avatar.309cd834.png",
"static/media/mdb-branding-transparent.svg": "./static/media/mdb-branding-transparent.edbb2b6f.svg",
Expand Down
9 changes: 0 additions & 9 deletions frontend/build-free/static/css/styles.115205e7.css

This file was deleted.

9 changes: 9 additions & 0 deletions frontend/build-free/static/css/styles.513ba96d.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion frontend/build-free/static/js/135.b3d3c2251903.chunk.js

This file was deleted.

Loading

0 comments on commit 3ec1276

Please sign in to comment.