Skip to content

Commit 3ec1276

Browse files
committed
Deploying version 2.7.0
1 parent f0bd63f commit 3ec1276

File tree

119 files changed

+852
-2841
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+852
-2841
lines changed

class/Common/Migration/MigrationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ function ajax_migrate_table()
368368
// need to split this up into a chunk and row_tracker
369369
// only strip the last new line if it exists
370370
$row_information = false !== strpos($response, "\n") ? trim(substr(strrchr($response, "\n"), 1)) : trim($response);
371-
$row_information = explode(',', $row_information);
371+
$row_information = explode('##MDB_SEPARATOR##', $row_information);
372372
$chunk = substr($response, 0, strrpos($response, ";\n") + 1);
373373

374374
if (!empty($chunk)) {

class/Common/Replace.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -769,12 +769,28 @@ protected function should_do_reference_check($table_prefix)
769769
if ( $this->table_is('options', $table_prefix) && 'option_value' === $this->get_column()) {
770770
return true;
771771
}
772-
if ( $table_prefix . 'duplicator_packages' === $this->get_table() && 'package' === $this->get_column() ) {
773-
return true;
774-
}
775-
if ( $table_prefix . 'aiowps_audit_log' === $this->get_table() && 'stacktrace' === $this->get_column() ) {
776-
return true;
772+
$table_column_for_check = [
773+
[
774+
'table' => $table_prefix . 'duplicator_packages',
775+
'column' => 'package'
776+
],
777+
[
778+
'table' => $table_prefix . 'aiowps_audit_log',
779+
'column' => 'stacktrace'
780+
]
781+
];
782+
$table_column_for_check = apply_filters('wpmdb_check_table_column_for_reference', $table_column_for_check);
783+
foreach($table_column_for_check as $table_column ) {
784+
if (
785+
array_key_exists('table', $table_column)
786+
&& $table_column['table'] === $this->get_table()
787+
&& array_key_exists('column', $table_column)
788+
&& $table_column['column'] === $this->get_column()
789+
) {
790+
return true;
791+
}
777792
}
793+
778794
return false;
779795
}
780796

class/Common/Sql/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,7 @@ function transfer_chunk($fp, $state_data)
17291729
}
17301730

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

17351735
return $result;

class/Common/Sql/TableHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function format_dump_name($dump_name)
196196
* @param string $scope Optional type of table to match against, default is 'table'.
197197
* @param string $new_prefix Optional new prefix already added to $given_table.
198198
* @param int $blog_id Optional Only used with 'blog' scope to test against a specific subsite's tables other than current for $wpdb.
199+
* @param string $source_prefix Optional prefix from source site already added to $given_table.
199200
*
200201
* @return boolean
201202
*/

class/Free/PluginUpdater.php

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
<?php
2+
/**
3+
* The PluginUpdater class which can be used to pull plugin updates from a new location.
4+
* @package wp-migrate-db
5+
*/
6+
7+
namespace DeliciousBrains\WPMDB\Free;
8+
9+
// Exit if accessed directly.
10+
if ( ! defined( 'ABSPATH' ) ) {
11+
exit;
12+
}
13+
14+
use stdClass;
15+
16+
/**
17+
* The PluginUpdater class which can be used to pull plugin updates from a new location.
18+
*/
19+
class PluginUpdater {
20+
/**
21+
* The URL where the api is located.
22+
* @var ApiUrl
23+
*/
24+
private $api_url;
25+
26+
/**
27+
* The amount of time to wait before checking for new updates.
28+
* @var CacheTime
29+
*/
30+
private $cache_time;
31+
32+
/**
33+
* These properties are passed in when instantiating to identify the plugin and it's update location.
34+
* @var Properties
35+
*/
36+
private $properties;
37+
38+
/**
39+
* Get the class constructed.
40+
*
41+
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
42+
*/
43+
public function __construct( $properties ) {
44+
if (
45+
empty( $properties['plugin_slug'] ) ||
46+
empty( $properties['plugin_basename'] )
47+
) {
48+
error_log( 'WPE Secure Plugin Updater received a malformed request.' );
49+
return;
50+
}
51+
52+
$this->api_url = 'https://wpe-plugin-updates.wpengine.com/';
53+
54+
$this->cache_time = time() + HOUR_IN_SECONDS * 5;
55+
56+
$this->properties = $this->get_full_plugin_properties( $properties, $this->api_url );
57+
58+
if ( ! $this->properties ) {
59+
return;
60+
}
61+
62+
$this->register();
63+
}
64+
65+
/**
66+
* Get the full plugin properties, including the directory name, version, basename, and add a transient name.
67+
*
68+
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
69+
* @param ApiUrl $api_url The URL where the api is located.
70+
*/
71+
public function get_full_plugin_properties( $properties, $api_url ) {
72+
$plugins = \get_plugins();
73+
74+
// Scan through all plugins installed and find the one which matches this one in question.
75+
foreach ( $plugins as $plugin_basename => $plugin_data ) {
76+
// Match using the passed-in plugin's basename.
77+
if ( $plugin_basename === $properties['plugin_basename'] ) {
78+
// Add the values we need to the properties.
79+
$properties['plugin_dirname'] = dirname( $plugin_basename );
80+
$properties['plugin_version'] = $plugin_data['Version'];
81+
$properties['plugin_update_transient_name'] = 'wpesu-plugin-' . sanitize_title( $properties['plugin_dirname'] );
82+
$properties['plugin_update_transient_exp_name'] = 'wpesu-plugin-' . sanitize_title( $properties['plugin_dirname'] ) . '-expiry';
83+
$properties['plugin_manifest_url'] = trailingslashit( $api_url ) . trailingslashit( $properties['plugin_slug'] ) . 'info.json';
84+
85+
return $properties;
86+
}
87+
}
88+
89+
// No matching plugin was found installed.
90+
return null;
91+
}
92+
93+
/**
94+
* Register hooks.
95+
*
96+
* @return void
97+
*/
98+
public function register() {
99+
add_filter( 'plugins_api', array( $this, 'filter_plugin_update_info' ), 20, 3 );
100+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'filter_plugin_update_transient' ) );
101+
}
102+
103+
/**
104+
* Filter the plugin update transient to take over update notifications.
105+
*
106+
* @param object $transient The site_transient_update_plugins transient.
107+
*
108+
* @handles site_transient_update_plugins
109+
* @return object
110+
*/
111+
public function filter_plugin_update_transient( $transient ) {
112+
// No update object exists. Return early.
113+
if ( empty( $transient ) ) {
114+
return $transient;
115+
}
116+
117+
$result = $this->fetch_plugin_info();
118+
119+
if ( false === $result ) {
120+
return $transient;
121+
}
122+
123+
if ( version_compare( $this->properties['plugin_version'], $result->version, '<' ) ) {
124+
$res = $this->parse_plugin_info( $result );
125+
$transient->response[ $res->plugin ] = $res;
126+
$transient->checked[ $res->plugin ] = $result->version;
127+
}
128+
129+
return $transient;
130+
}
131+
132+
/**
133+
* Filters the plugin update information.
134+
*
135+
* @param object $res The response to be modified for the plugin in question.
136+
* @param string $action The action in question.
137+
* @param object $args The arguments for the plugin in question.
138+
*
139+
* @handles plugins_api
140+
* @return object
141+
*/
142+
public function filter_plugin_update_info( $res, $action, $args ) {
143+
// Do nothing if this is not about getting plugin information.
144+
if ( 'plugin_information' !== $action ) {
145+
return $res;
146+
}
147+
148+
// Do nothing if it is not our plugin.
149+
if ( $this->properties['plugin_dirname'] !== $args->slug ) {
150+
return $res;
151+
}
152+
153+
$result = $this->fetch_plugin_info();
154+
155+
// Do nothing if we don't get the correct response from the server.
156+
if ( false === $result ) {
157+
return $res;
158+
}
159+
160+
return $this->parse_plugin_info( $result );
161+
}
162+
163+
/**
164+
* Fetches the plugin update object from the WP Product Info API.
165+
*
166+
* @return object|false
167+
*/
168+
private function fetch_plugin_info() {
169+
// Fetch cache first.
170+
$expiry = get_option( $this->properties['plugin_update_transient_exp_name'], 0 );
171+
$response = get_option( $this->properties['plugin_update_transient_name'] );
172+
173+
if ( empty( $expiry ) || time() > $expiry || empty( $response ) ) {
174+
$response = wp_remote_get(
175+
$this->properties['plugin_manifest_url'],
176+
array(
177+
'timeout' => 10,
178+
'headers' => array(
179+
'Accept' => 'application/json',
180+
),
181+
)
182+
);
183+
184+
if (
185+
is_wp_error( $response ) ||
186+
200 !== wp_remote_retrieve_response_code( $response ) ||
187+
empty( wp_remote_retrieve_body( $response ) )
188+
) {
189+
return false;
190+
}
191+
192+
$response = wp_remote_retrieve_body( $response );
193+
194+
// Cache the response.
195+
update_option( $this->properties['plugin_update_transient_exp_name'], $this->cache_time, false );
196+
update_option( $this->properties['plugin_update_transient_name'], $response, false );
197+
}
198+
199+
$decoded_response = json_decode( $response );
200+
201+
if ( json_last_error() !== JSON_ERROR_NONE ) {
202+
return false;
203+
}
204+
205+
return $decoded_response;
206+
}
207+
208+
/**
209+
* Parses the product info response into an object that WordPress would be able to understand.
210+
*
211+
* @param object $response The response object.
212+
*
213+
* @return stdClass
214+
*/
215+
private function parse_plugin_info( $response ) {
216+
217+
global $wp_version;
218+
219+
$res = new stdClass();
220+
$res->name = $response->name;
221+
$res->slug = $response->slug;
222+
$res->version = $response->version;
223+
$res->requires = $response->requires;
224+
$res->download_link = $response->download_link;
225+
$res->trunk = $response->download_link;
226+
$res->new_version = $response->version;
227+
$res->plugin = $this->properties['plugin_basename'];
228+
$res->package = $response->download_link;
229+
230+
// Plugin information modal and core update table use a strict version comparison, which is weird.
231+
// If we're genuinely not compatible with the point release, use our WP tested up to version.
232+
// otherwise use exact same version as WP to avoid false positive.
233+
$res->tested = 1 === version_compare( substr( $wp_version, 0, 3 ), $response->tested )
234+
? $response->tested
235+
: $wp_version;
236+
237+
$res->sections = array(
238+
'description' => $response->sections->description,
239+
'changelog' => $response->sections->changelog,
240+
);
241+
242+
return $res;
243+
}
244+
}

frontend/build-free/asset-manifest.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"main.js": "./static/js/main.34c987d7aaaa.js",
3-
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.2e36fba1b35e.js",
4-
"static/js/879.a33252bbf8ac.chunk.js": "./static/js/879.a33252bbf8ac.chunk.js",
5-
"static/js/897.d633170df3fa.chunk.js": "./static/js/897.d633170df3fa.chunk.js",
6-
"static/js/613.7f5d74d1cf11.chunk.js": "./static/js/613.7f5d74d1cf11.chunk.js",
7-
"static/js/513.f8a4a9bce00e.chunk.js": "./static/js/513.f8a4a9bce00e.chunk.js",
8-
"static/js/406.f7351d7a08c9.chunk.js": "./static/js/406.f7351d7a08c9.chunk.js",
9-
"static/js/537.b4fd8a6d5c2b.chunk.js": "./static/js/537.b4fd8a6d5c2b.chunk.js",
10-
"static/js/605.b86b7a09a985.chunk.js": "./static/js/605.b86b7a09a985.chunk.js",
11-
"styles.css": "./static/css/styles.115205e7.css",
12-
"styles.js": "./static/js/styles.5894c30f8136.js",
13-
"static/js/634.aadc01a62e9d.js": "./static/js/634.aadc01a62e9d.js",
14-
"static/js/358.abfefc366410.chunk.js": "./static/js/358.abfefc366410.chunk.js",
15-
"static/js/135.b3d3c2251903.chunk.js": "./static/js/135.b3d3c2251903.chunk.js",
2+
"main.js": "./static/js/main.403d4d6fe1d8.js",
3+
"wpmdb-runtime.js": "./static/js/wpmdb-runtime.23f4ea227134.js",
4+
"static/js/800.e69dbe829c57.chunk.js": "./static/js/800.e69dbe829c57.chunk.js",
5+
"static/js/359.8631588d52dc.chunk.js": "./static/js/359.8631588d52dc.chunk.js",
6+
"static/js/481.adbbff83ff0c.chunk.js": "./static/js/481.adbbff83ff0c.chunk.js",
7+
"static/js/56.109cbdac7eb4.chunk.js": "./static/js/56.109cbdac7eb4.chunk.js",
8+
"static/js/203.cb0dadc2e016.chunk.js": "./static/js/203.cb0dadc2e016.chunk.js",
9+
"static/js/85.8a8af69d7986.chunk.js": "./static/js/85.8a8af69d7986.chunk.js",
10+
"static/js/384.d12a10c3ebbb.chunk.js": "./static/js/384.d12a10c3ebbb.chunk.js",
11+
"styles.css": "./static/css/styles.513ba96d.css",
12+
"styles.js": "./static/js/styles.7699beeb2cf2.js",
13+
"static/js/652.c7184786a47f.js": "./static/js/652.c7184786a47f.js",
14+
"static/js/898.d64597f6c89a.chunk.js": "./static/js/898.d64597f6c89a.chunk.js",
15+
"static/js/970.185a31a710b6.chunk.js": "./static/js/970.185a31a710b6.chunk.js",
1616
"static/media/wp-migrate-2-6-0.png": "./static/media/wp-migrate-2-6-0.8d26599e.png",
1717
"static/media/testimonial-avatar.png": "./static/media/testimonial-avatar.309cd834.png",
1818
"static/media/mdb-branding-transparent.svg": "./static/media/mdb-branding-transparent.edbb2b6f.svg",

frontend/build-free/static/css/styles.115205e7.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

frontend/build-free/static/css/styles.513ba96d.css

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/build-free/static/js/135.b3d3c2251903.chunk.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)