updated plugin Jetpack Protect version 3.0.2

This commit is contained in:
2024-10-09 12:44:31 +00:00
committed by Gitium
parent a35dc419bc
commit f970470c59
283 changed files with 6970 additions and 2338 deletions

View File

@ -5,6 +5,119 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [3.10.0] - 2024-09-05
### Added
- Sync: Add a filter that allows modification of the default modules list used for full sync procedure. [#39117]
## [3.9.1] - 2024-09-05
### Changed
- Optimized performance by moving the IDC safe mode check after the connection check, reducing unnecessary get_option() requests for jetpack_sync_error_idc [#39205]
### Fixed
- Jetpack sync: Gutenberg footnotes meta [#38878]
## [3.9.0] - 2024-08-30
### Added
- Add share status log modal to published posts [#39051]
## [3.8.1] - 2024-08-29
### Changed
- Sync: Add subscription type for HPOS orders only if WooCommerce Subscriptions plugin exists [#39118]
## [3.8.0] - 2024-08-26
### Changed
- Sync: Updated allowed order types in HPOS Module [#39022]
### Fixed
- Sync: Ensure filtering orders by status when doing HPOS Checksums [#39020]
## [3.7.1] - 2024-08-23
### Changed
- Updated package dependencies. [#39004]
## [3.7.0] - 2024-08-21
### Added
- Synced Order Data: adds filtering to the filtered order data [#38955]
## [3.6.0] - 2024-08-15
### Added
- Sync: Add a new callable for Sync Active Modules [#38831]
### Fixed
- Fix incorrect next-version tokens in php `@since` and/or `@deprecated` docs. [#38869]
- Sync: update WooCommerce Post Meta whitelist. [#38677]
## [3.5.1] - 2024-08-08
### Fixed
- Sync: Fix integration of Brute Force Login Protection [#38518]
## [3.5.0] - 2024-08-06
### Changed
- Sync: Change fields for HPOS checksums [#38713]
## [3.4.1] - 2024-08-05
### Fixed
- Jetpack Sync: Take order type into account when performing HPOS Checksums [#38688]
## [3.4.0] - 2024-07-29
### Added
- Add support for syncing Jetpack WAF options. [#37957]
## [3.3.1] - 2024-07-26
### Fixed
- Jetpack Sync: Ensure duplicate Sync modules are not loaded [#38503]
## [3.3.0] - 2024-07-15
### Added
- Jetpack Sync: Add support for HPOS checksums [#38320]
### Changed
- Jetpack Sync: Ensure HPOS order status is prefixed with 'wc-' before sending it to WPCOM [#38258]
## [3.2.1] - 2024-07-10
### Fixed
- Jetpack Sync HPOS: Ensure get_objects_by_id will return all relevant orders [#38251]
## [3.2.0] - 2024-07-08
### Changed
- Jetpack Sync: Ensure we always sync heartbeat data and active plugins no matter the consumer config [#38135]
### Fixed
- Jetpack Sync: Fix HPOS checksum support for wc_order_operational_data [#38191]
- Sync: Fix bug in WooCommerce_HPOS_Orders::get_objects_by_id method [#38192]
## [3.1.4] - 2024-07-01
### Fixed
- Sync Checksum:Use postmeta table name from wpdb to compare so we don't filter by whitelist due to performance reasons. [#38084]
## [3.1.3] - 2024-06-25
### Changed
- Internal updates.
## [3.1.2] - 2024-06-21
### Added
- Adding a new toggles to control the newsletter byline [#37916]
## [3.1.1] - 2024-06-13
### Changed
- Internal updates.
## [3.1.0] - 2024-06-10
### Added
- Staging: deprecating staging mode and separating the logic into is_development_site and in_safe_mode [#37023]
## [3.0.2] - 2024-06-04
### Fixed
- Defaults: Add new item to default_theme_support_whitelist to prevent failing sync tests. [#37701]
## [3.0.1] - 2024-05-29
### Changed
- Remove the 'jetpack-identity-crisis' dependency. [#36968]
## [3.0.0] - 2024-05-27
### Removed
- Jetpack Sync: Remove 'admin_action_update' hook from Sync Plugins module. [#37488]
## [2.16.6] - 2024-05-23
### Added
- Add reply to name setting for newsletters. [#37362]
@ -1160,6 +1273,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Packages: Move sync to a classmapped package
[3.10.0]: https://github.com/Automattic/jetpack-sync/compare/v3.9.1...v3.10.0
[3.9.1]: https://github.com/Automattic/jetpack-sync/compare/v3.9.0...v3.9.1
[3.9.0]: https://github.com/Automattic/jetpack-sync/compare/v3.8.1...v3.9.0
[3.8.1]: https://github.com/Automattic/jetpack-sync/compare/v3.8.0...v3.8.1
[3.8.0]: https://github.com/Automattic/jetpack-sync/compare/v3.7.1...v3.8.0
[3.7.1]: https://github.com/Automattic/jetpack-sync/compare/v3.7.0...v3.7.1
[3.7.0]: https://github.com/Automattic/jetpack-sync/compare/v3.6.0...v3.7.0
[3.6.0]: https://github.com/Automattic/jetpack-sync/compare/v3.5.1...v3.6.0
[3.5.1]: https://github.com/Automattic/jetpack-sync/compare/v3.5.0...v3.5.1
[3.5.0]: https://github.com/Automattic/jetpack-sync/compare/v3.4.1...v3.5.0
[3.4.1]: https://github.com/Automattic/jetpack-sync/compare/v3.4.0...v3.4.1
[3.4.0]: https://github.com/Automattic/jetpack-sync/compare/v3.3.1...v3.4.0
[3.3.1]: https://github.com/Automattic/jetpack-sync/compare/v3.3.0...v3.3.1
[3.3.0]: https://github.com/Automattic/jetpack-sync/compare/v3.2.1...v3.3.0
[3.2.1]: https://github.com/Automattic/jetpack-sync/compare/v3.2.0...v3.2.1
[3.2.0]: https://github.com/Automattic/jetpack-sync/compare/v3.1.4...v3.2.0
[3.1.4]: https://github.com/Automattic/jetpack-sync/compare/v3.1.3...v3.1.4
[3.1.3]: https://github.com/Automattic/jetpack-sync/compare/v3.1.2...v3.1.3
[3.1.2]: https://github.com/Automattic/jetpack-sync/compare/v3.1.1...v3.1.2
[3.1.1]: https://github.com/Automattic/jetpack-sync/compare/v3.1.0...v3.1.1
[3.1.0]: https://github.com/Automattic/jetpack-sync/compare/v3.0.2...v3.1.0
[3.0.2]: https://github.com/Automattic/jetpack-sync/compare/v3.0.1...v3.0.2
[3.0.1]: https://github.com/Automattic/jetpack-sync/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/Automattic/jetpack-sync/compare/v2.16.6...v3.0.0
[2.16.6]: https://github.com/Automattic/jetpack-sync/compare/v2.16.5...v2.16.6
[2.16.5]: https://github.com/Automattic/jetpack-sync/compare/v2.16.4...v2.16.5
[2.16.4]: https://github.com/Automattic/jetpack-sync/compare/v2.16.3...v2.16.4

View File

@ -5,19 +5,18 @@
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.0",
"automattic/jetpack-connection": "^2.8.4",
"automattic/jetpack-constants": "^2.0.2",
"automattic/jetpack-identity-crisis": "^0.20.0",
"automattic/jetpack-password-checker": "^0.3.1",
"automattic/jetpack-ip": "^0.2.2",
"automattic/jetpack-roles": "^2.0.2",
"automattic/jetpack-status": "^3.2.0"
"automattic/jetpack-connection": "^4.0.0",
"automattic/jetpack-constants": "^2.0.4",
"automattic/jetpack-password-checker": "^0.3.2",
"automattic/jetpack-ip": "^0.2.3",
"automattic/jetpack-roles": "^2.0.3",
"automattic/jetpack-status": "^4.0.0"
},
"require-dev": {
"automattic/jetpack-changelogger": "^4.2.4",
"yoast/phpunit-polyfills": "1.1.0",
"automattic/jetpack-changelogger": "^4.2.6",
"yoast/phpunit-polyfills": "^1.1.1",
"automattic/jetpack-search": "@dev",
"automattic/jetpack-waf": "^0.16.8",
"automattic/jetpack-waf": "@dev",
"automattic/wordbless": "@dev"
},
"suggest": {
@ -51,7 +50,7 @@
"link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "2.16.x-dev"
"dev-trunk": "3.10.x-dev"
},
"dependencies": {
"test-only": [

View File

@ -304,10 +304,6 @@ class Actions {
return false;
}
if ( ( new Status() )->is_staging_site() ) {
return false;
}
$connection = new Jetpack_Connection();
if ( ! $connection->is_connected() ) {
if ( ! doing_action( 'jetpack_site_registered' ) ) {
@ -315,6 +311,11 @@ class Actions {
}
}
// By now, we know the site is connected, so we can return false if in safe mode.
if ( ( new Status() )->in_safe_mode() ) {
return false;
}
return true;
}
@ -342,8 +343,8 @@ class Actions {
if ( ( new Status() )->is_offline_mode() ) {
$debug['debug_details']['is_offline_mode'] = true;
}
if ( ( new Status() )->is_staging_site() ) {
$debug['debug_details']['is_staging_site'] = true;
if ( ( new Status() )->in_safe_mode() ) {
$debug['debug_details']['in_safe_mode'] = true;
}
$connection = new Jetpack_Connection();
if ( ! $connection->is_connected() ) {

View File

@ -22,18 +22,20 @@ class Data_Settings {
'Automattic\\Jetpack\\Sync\\Modules\\Full_Sync_Immediately', // enable Initial Sync on Site Connection.
'Automattic\\Jetpack\\Sync\\Modules\\Options',
'Automattic\\Jetpack\\Sync\\Modules\\Updates',
'Automattic\\Jetpack\\Sync\\Modules\\Stats', // Daily heartbeat data.
),
'jetpack_sync_callable_whitelist' => array(
'site_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'site_url' ),
'home_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'home_url' ),
'get_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
'get_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_themes' ),
'paused_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
'paused_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
'timezone' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
'wp_get_environment_type' => 'wp_get_environment_type',
'wp_max_upload_size' => 'wp_max_upload_size',
'wp_version' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
'site_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'site_url' ),
'home_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'home_url' ),
'get_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
'get_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_themes' ),
'jetpack_connection_active_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_connection_active_plugins' ),
'paused_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
'paused_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
'timezone' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
'wp_get_environment_type' => 'wp_get_environment_type',
'wp_max_upload_size' => 'wp_max_upload_size',
'wp_version' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
),
'jetpack_sync_constants_whitelist' => array(
'ABSPATH',
@ -73,7 +75,6 @@ class Data_Settings {
/**
* Connection related options
*/
'jetpack_connection_active_plugins',
'jetpack_package_versions',
/**
* Generic site options
@ -86,6 +87,7 @@ class Data_Settings {
'stylesheet',
'time_format',
'timezone_string',
'active_plugins',
),
);

View File

@ -292,7 +292,7 @@ class Dedicated_Sender {
* Test Sync spawning functionality by making a request to the
* Sync spawning endpoint and storing the result (status code) in a transient.
*
* @since $$next_version$$
* @since 1.34.0
*
* @return bool True if we got a successful response, false otherwise.
*/

View File

@ -78,7 +78,6 @@ class Defaults {
'jetpack_available_modules',
'jetpack_comment_form_color_scheme',
'jetpack_comment_likes_enabled',
'jetpack_connection_active_plugins',
'jetpack_excluded_extensions',
'jetpack_mailchimp',
'jetpack_options',
@ -186,6 +185,9 @@ class Defaults {
'wpcom_ai_site_prompt',
'wpcom_classic_early_release',
'wpcom_featured_image_in_email',
'jetpack_gravatar_in_email',
'jetpack_author_in_email',
'jetpack_post_date_in_email',
'wpcom_gifting_subscription',
'wpcom_is_fse_activated',
'wpcom_legacy_contact',
@ -204,6 +206,14 @@ class Defaults {
'jetpack_package_versions',
'jetpack_newsletters_publishing_default_frequency',
'jetpack_scheduled_plugins_update',
'jetpack_waf_automatic_rules',
'jetpack_waf_ip_allow_list',
'jetpack_waf_ip_allow_list_enabled',
'jetpack_waf_ip_block_list',
'jetpack_waf_ip_block_list_enabled',
'jetpack_waf_share_data',
'jetpack_waf_share_debug_data',
'jetpack_waf_automatic_rules_last_updated_timestamp',
);
/**
@ -314,37 +324,39 @@ class Defaults {
* @var array Default whitelist of callables.
*/
public static $default_callable_whitelist = array(
'get_loaded_extensions' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_loaded_extensions' ),
'get_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
'get_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_themes' ),
'get_plugins_action_links' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins_action_links' ),
'has_file_system_write_access' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'file_system_write_access' ),
'home_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'home_url' ),
'hosting_provider' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_hosting_provider' ),
'is_fse_theme' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_is_fse_theme' ),
'is_main_network' => array( __CLASS__, 'is_multi_network' ),
'is_multi_site' => 'is_multisite',
'is_version_controlled' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'is_version_controlled' ),
'locale' => 'get_locale',
'main_network_site' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'main_network_site_url' ),
'main_network_site_wpcom_id' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'main_network_site_wpcom_id' ),
'paused_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
'paused_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
'post_type_features' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_type_features' ),
'post_types' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_types' ),
'rest_api_allowed_post_types' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_post_types' ),
'rest_api_allowed_public_metadata' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_public_metadata' ),
'roles' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'roles' ),
'shortcodes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_shortcodes' ),
'site_icon_url' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'site_icon_url' ),
'site_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'site_url' ),
'taxonomies' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_taxonomies' ),
'theme_support' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_theme_support' ),
'timezone' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
'wp_get_environment_type' => 'wp_get_environment_type',
'wp_max_upload_size' => 'wp_max_upload_size',
'wp_version' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
'active_modules' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_active_modules' ),
'get_loaded_extensions' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_loaded_extensions' ),
'get_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins' ),
'get_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_themes' ),
'get_plugins_action_links' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_plugins_action_links' ),
'has_file_system_write_access' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'file_system_write_access' ),
'home_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'home_url' ),
'hosting_provider' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_hosting_provider' ),
'is_fse_theme' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_is_fse_theme' ),
'is_main_network' => array( __CLASS__, 'is_multi_network' ),
'is_multi_site' => 'is_multisite',
'is_version_controlled' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'is_version_controlled' ),
'locale' => 'get_locale',
'main_network_site' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'main_network_site_url' ),
'main_network_site_wpcom_id' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'main_network_site_wpcom_id' ),
'paused_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_plugins' ),
'paused_themes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_paused_themes' ),
'post_type_features' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_type_features' ),
'post_types' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_post_types' ),
'rest_api_allowed_post_types' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_post_types' ),
'rest_api_allowed_public_metadata' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'rest_api_allowed_public_metadata' ),
'roles' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'roles' ),
'shortcodes' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_shortcodes' ),
'site_icon_url' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'site_icon_url' ),
'site_url' => array( 'Automattic\\Jetpack\\Connection\\Urls', 'site_url' ),
'taxonomies' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_taxonomies' ),
'theme_support' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_theme_support' ),
'timezone' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_timezone' ),
'wp_get_environment_type' => 'wp_get_environment_type',
'wp_max_upload_size' => 'wp_max_upload_size',
'wp_version' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'wp_version' ),
'active_modules' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_active_modules' ),
'jetpack_connection_active_plugins' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_connection_active_plugins' ),
'jetpack_sync_active_modules' => array( 'Automattic\\Jetpack\\Sync\\Functions', 'get_jetpack_sync_active_modules' ),
);
/**
@ -770,6 +782,7 @@ class Defaults {
'videopress_guid',
'vimeo_poster_image',
'_jetpack_blogging_prompt_key',
'footnotes', // Core footnotes block
);
/**
@ -850,6 +863,7 @@ class Defaults {
'editor-color-palette',
'editor-font-sizes',
'editor-gradient-presets',
'editor-spacing-sizes',
'editor-style', // deprecated.
'editor-styles',
'html5',

View File

@ -7,6 +7,7 @@
namespace Automattic\Jetpack\Sync;
use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Connection\Urls;
use Automattic\Jetpack\Constants;
use Automattic\Jetpack\Modules as Jetpack_Modules;
@ -666,7 +667,7 @@ class Functions {
/**
* Return the list of active Jetpack modules.
*
* @since $$next_version$$
* @since 1.34.0
*
* @return array
*/
@ -677,7 +678,7 @@ class Functions {
/**
* Return a list of PHP modules that we want to track.
*
* @since $$next_version$$
* @since 1.50.0
*
* @return array
*/
@ -709,4 +710,31 @@ class Functions {
return $enabled_extensions;
}
/**
* Return the list of active connected Jetpack plugins.
*
* @since 3.2.0
*
* @return array
*/
public static function get_jetpack_connection_active_plugins() {
return ( new Manager() )->get_connected_plugins();
}
/**
* Return the list of active sync modules.
*
* @since 3.6.0
*
* @return array
*/
public static function get_jetpack_sync_active_modules() {
/** This filter is documented in projects/packages/sync/src/class-modules.php */
$modules = apply_filters( 'jetpack_sync_modules', Modules::DEFAULT_SYNC_MODULES );
$modules = array_unique( $modules );
$modules = array_map( 'wp_normalize_path', $modules );
return $modules;
}
}

View File

@ -113,6 +113,7 @@ class Modules {
* @return array
*/
public static function initialize_modules() {
/**
* Filters the list of class names of sync modules.
* If you add to this list, make sure any classes implement the
@ -123,8 +124,9 @@ class Modules {
*/
$modules = apply_filters( 'jetpack_sync_modules', self::DEFAULT_SYNC_MODULES );
$modules = array_map( array( __CLASS__, 'load_module' ), $modules );
$modules = array_unique( $modules );
$modules = array_map( array( __CLASS__, 'load_module' ), $modules );
return array_map( array( __CLASS__, 'set_module_defaults' ), $modules );
}

View File

@ -12,7 +12,7 @@ namespace Automattic\Jetpack\Sync;
*/
class Package_Version {
const PACKAGE_VERSION = '2.16.6';
const PACKAGE_VERSION = '3.10.0';
const PACKAGE_SLUG = 'sync';

View File

@ -1175,7 +1175,6 @@ class Replicastore implements Replicastore_Interface {
/**
* Retrieve all the checksums we are interested in.
* Currently that is posts, comments, post meta and comment meta.
*
* @access public
*
@ -1238,6 +1237,29 @@ class Replicastore implements Replicastore_Interface {
} catch ( Exception $ex ) {
$result['woocommerce_order_itemmeta'] = null;
}
if ( Table_Checksum::enable_woocommerce_hpos_tables() ) {
try {
$woocommerce_hpos_orders_checksum = $this->checksum_histogram( 'wc_orders' );
$result['wc_orders'] = $this->summarize_checksum_histogram( $woocommerce_hpos_orders_checksum );
} catch ( Exception $ex ) {
$result['wc_orders'] = null;
}
try {
$woocommerce_hpos_order_addresses_checksum = $this->checksum_histogram( 'wc_order_addresses' );
$result['wc_order_addresses'] = $this->summarize_checksum_histogram( $woocommerce_hpos_order_addresses_checksum );
} catch ( Exception $ex ) {
$result['wc_order_addresses'] = null;
}
try {
$woocommerce_hpos_order_operational_data_checksum = $this->checksum_histogram( 'wc_order_operational_data' );
$result['wc_order_operational_data'] = $this->summarize_checksum_histogram( $woocommerce_hpos_order_operational_data_checksum );
} catch ( Exception $ex ) {
$result['wc_order_operational_data'] = null;
}
}
}
return $result;

View File

@ -288,7 +288,7 @@ class REST_Endpoints {
'required' => false,
),
'only_range_edges' => array(
'description' => __( 'Should only range endges be returned', 'jetpack-sync' ),
'description' => __( 'Should only range edges be returned', 'jetpack-sync' ),
'type' => 'boolean',
'required' => false,
),
@ -764,7 +764,7 @@ class REST_Endpoints {
* @see Actions::init
* @see Sender::do_dedicated_sync_and_exit
*
* @since $$next_version$$
* @since 1.34.0
*
* @return \WP_REST_Response
*/

View File

@ -80,7 +80,14 @@ class Full_Sync_Immediately extends Module {
$this->reset_data();
if ( ! is_array( $full_sync_config ) ) {
$full_sync_config = Defaults::$default_full_sync_config;
/*
* Filter default sync config to allow injecting custom configuration.
*
* @param array $full_sync_config Sync configuration for all sync modules.
*
* @since 3.10.0
*/
$full_sync_config = apply_filters( 'jetpack_full_sync_config', Defaults::$default_full_sync_config );
if ( is_multisite() ) {
$full_sync_config['network_options'] = 1;
}

View File

@ -71,7 +71,6 @@ class Plugins extends Module {
add_action( 'jetpack_plugin_installed', $callable, 10, 1 );
add_action( 'jetpack_plugin_update_failed', $callable, 10, 4 );
add_action( 'jetpack_plugins_updated', $callable, 10, 2 );
add_action( 'admin_action_update', array( $this, 'check_plugin_edit' ) );
add_action( 'jetpack_edited_plugin', $callable, 10, 2 );
add_action( 'wp_ajax_edit-theme-plugin-file', array( $this, 'plugin_edit_ajax' ), 0 );
@ -245,39 +244,6 @@ class Plugins extends Module {
return false;
}
/**
* Handle plugin edit in the administration.
*
* @access public
*
* @todo The `admin_action_update` hook is called only for logged in users, but maybe implement nonce verification?
*/
public function check_plugin_edit() {
$screen = get_current_screen();
// phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( 'plugin-editor' !== $screen->base || ! isset( $_POST['newcontent'] ) || ! isset( $_POST['plugin'] ) ) {
return;
}
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated manually just after.
$plugin = wp_unslash( $_POST['plugin'] );
$plugins = get_plugins();
if ( ! isset( $plugins[ $plugin ] ) ) {
return;
}
/**
* Helps Sync log that a plugin was edited
*
* @since 1.6.3
* @since-jetpack 4.9.0
*
* @param string $plugin, Plugin slug
* @param mixed $plugins[ $plugin ], Array of plugin data
*/
do_action( 'jetpack_edited_plugin', $plugin, $plugins[ $plugin ] );
}
/**
* Handle plugin ajax edit in the administration.
*

View File

@ -38,6 +38,23 @@ class Protect extends Module {
add_action( 'jetpack_valid_failed_login_attempt', $callback );
}
/**
* Provide a fallback value for has_login_ability.
*
* @access private
*/
private function has_login_ability_fallback() {
// Fall back to the Brute Force Protection class if it is available.
if ( class_exists( 'Brute_Force_Protection' ) ) {
$brute_force_protection = Brute_Force_Protection::instance();
return $brute_force_protection->has_login_ability();
}
// If the login ability can not be determined, the feature is not active,
// or something is wrong, default to not syncing failed login attempts.
return false;
}
/**
* Maybe log a failed login attempt.
*
@ -46,8 +63,20 @@ class Protect extends Module {
* @param array $failed_attempt Failed attempt data.
*/
public function maybe_log_failed_login_attempt( $failed_attempt ) {
$brute_force_protection = Brute_Force_Protection::instance();
if ( $brute_force_protection->has_login_ability() && ! Jetpack_Constants::is_true( 'XMLRPC_REQUEST' ) ) {
/**
* Filter which provides Jetpack's decision as to whether the current requestor can attempt logging in.
*
* Example: When Jetpack's Brute Force Login Protection is active, this filter will return false if the user is currently locked out.
*
* @since 3.5.1
*
* @package sync
*
* @return bool True if the user should be allowed to attempt logging in, false otherwise.
*/
$has_login_ability = apply_filters( 'jetpack_has_login_ability', $this->has_login_ability_fallback() );
if ( $has_login_ability && ! Jetpack_Constants::is_true( 'XMLRPC_REQUEST' ) ) {
do_action( 'jetpack_valid_failed_login_attempt', $failed_attempt );
}
}

View File

@ -14,6 +14,11 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
*/
class WooCommerce_HPOS_Orders extends Module {
/**
* The slug of WooCommerce Subscriptions plugin.
*/
const WOOCOMMERCE_SUBSCRIPTIONS_PATH = 'woocommerce-subscriptions/woocommerce-subscriptions.php';
/**
* Order table name. There are four order tables (order, addresses, operational_data and meta), but for sync purposes we only care about the main table since it has the order ID.
*
@ -60,14 +65,17 @@ class WooCommerce_HPOS_Orders extends Module {
/**
* Get order types that we want to sync. Adding a new type here is not enough, we would also need to add its prop in filter_order_data method.
*
* @access private
*
* @param bool $prefixed Whether to return prefixed types with shop_ or not.
*
* @return array Order types to sync.
*/
private function get_order_types_to_sync( $prefixed = false ) {
public static function get_order_types_to_sync( $prefixed = false ) {
$types = array( 'order', 'order_refund' );
if ( is_plugin_active( self::WOOCOMMERCE_SUBSCRIPTIONS_PATH ) ) {
$types[] = 'subscription';
}
if ( $prefixed ) {
$types = array_map(
function ( $type ) {
@ -87,7 +95,7 @@ class WooCommerce_HPOS_Orders extends Module {
* @param callable $callable Action handler callable.
*/
public function init_listeners( $callable ) {
foreach ( $this->get_order_types_to_sync() as $type ) {
foreach ( self::get_order_types_to_sync() as $type ) {
add_action( "woocommerce_after_{$type}_object_save", $callable );
add_filter( "jetpack_sync_before_enqueue_woocommerce_after_{$type}_object_save", array( $this, 'expand_order_object' ) );
}
@ -160,19 +168,24 @@ class WooCommerce_HPOS_Orders extends Module {
* @return array
*/
public function get_objects_by_id( $object_type, $ids ) {
if ( 'order' !== $object_type ) {
return $ids;
if ( 'order' !== $object_type || empty( $ids ) || ! is_array( $ids ) ) {
return array();
}
$orders = wc_get_orders(
$orders = wc_get_orders(
array(
'include' => $ids,
'type' => $this->get_order_types_to_sync( true ),
'post__in' => $ids,
'type' => self::get_order_types_to_sync( true ),
'post_status' => self::get_all_possible_order_status_keys(),
'limit' => -1,
)
);
$orders_data = array();
foreach ( $orders as $order ) {
$orders_data[ $order->get_id() ] = $this->filter_order_data( $order );
}
return $orders_data;
}
@ -298,8 +311,70 @@ class WooCommerce_HPOS_Orders extends Module {
if ( '' === $filtered_order_data['status'] ) {
$filtered_order_data['status'] = 'pending';
}
$filtered_order_data['status'] = self::get_wc_order_status_with_prefix( $filtered_order_data['status'] );
return $filtered_order_data;
/**
* Filter the order data before syncing.
*
* @since 3.7.0
*
* @param array $filtered_order_data The Filtered order data.
* @param \WC_Abstract_Order $order_object The Order object.
*/
return apply_filters( 'jetpack_sync_filtered_hpos_order_data', $filtered_order_data, $order_object );
}
/**
* Returns all possible order status keys, including 'auto-draft' and 'trash'.
*
* @access public
*
* @return array An array of all possible status keys, including 'auto-draft' and 'trash'.
*/
public static function get_all_possible_order_status_keys() {
$order_statuses = array( 'auto-draft', 'trash' );
$wc_order_statuses = self::wc_get_order_status_keys();
return array_unique( array_merge( $wc_order_statuses, $order_statuses ) );
}
/**
* Add the 'wc-' order status to WC related order statuses.
*
* @param string $status The WC order status without the 'wc-' prefix.
*
* @return string The WC order status with the 'wc-' prefix if it's a valid order status, initial $status otherwise.
*/
protected static function get_wc_order_status_with_prefix( string $status ) {
return in_array( 'wc-' . $status, self::wc_get_order_status_keys(), true ) ? 'wc-' . $status : $status;
}
/**
* Returns order status keys using 'wc_get_order_statuses', if possible.
*
* @see wc_get_order_statuses
*
* @return array Filtered order metadata.
*/
private static function wc_get_order_status_keys() {
$wc_order_statuses = array();
if ( function_exists( 'wc_get_order_statuses' ) ) {
$wc_order_statuses = array_keys( wc_get_order_statuses() );
$wc_order_statuses[] = 'wc-checkout-draft'; // Temp till Woo fixes a bug where this order status is missing.
} else {
$wc_order_statuses = array(
'wc-pending',
'wc-processing',
'wc-on-hold',
'wc-completed',
'wc-cancelled',
'wc-refunded',
'wc-failed',
'wc-checkout-draft',
);
}
return array_unique( $wc_order_statuses );
}
/**
@ -361,7 +436,7 @@ class WooCommerce_HPOS_Orders extends Module {
public function get_where_sql( $config ) {
global $wpdb;
$parent_where = parent::get_where_sql( $config );
$order_types = $this->get_order_types_to_sync( true );
$order_types = self::get_order_types_to_sync( true );
$order_type_placeholder = implode( ', ', array_fill( 0, count( $order_types ), '%s' ) );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare -- Query is prepared.
$where_sql = $wpdb->prepare( "type IN ( $order_type_placeholder )", $order_types );

View File

@ -549,14 +549,15 @@ class WooCommerce extends Module {
'_date_completed',
'_date_paid',
'_payment_tokens',
'_billing_address_index',
'_shipping_address_index',
// '_billing_address_index', do not sync these as they contain personal data.
// '_shipping_address_index',
'_recorded_sales',
'_recorded_coupon_usage_counts',
// See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-order-data-store-cpt.php#L539 .
'_download_permissions_granted',
// See https://github.com/woocommerce/woocommerce/blob/8ed6e7436ff87c2153ed30edd83c1ab8abbdd3e9/includes/data-stores/class-wc-order-data-store-cpt.php#L594 .
'_order_stock_reduced',
'_cart_hash',
// Woocommerce order refunds.
// See https://github.com/woocommerce/woocommerce/blob/b8a2815ae546c836467008739e7ff5150cb08e93/includes/data-stores/class-wc-order-refund-data-store-cpt.php#L20 .

View File

@ -8,6 +8,7 @@
namespace Automattic\Jetpack\Sync\Replicastore;
use Automattic\Jetpack\Sync;
use Automattic\Jetpack\Sync\Modules\WooCommerce_HPOS_Orders;
use Exception;
use WP_Error;
@ -311,25 +312,42 @@ class Table_Checksum {
'table' => "{$wpdb->prefix}wc_orders",
'range_field' => 'id',
'key_fields' => array( 'id' ),
'checksum_text_fields' => array( 'type', 'status', 'payment_method_title' ),
'filter_values' => array(),
'is_table_enabled_callback' => array( $this, 'enable_woocommerce_tables' ),
'checksum_fields' => array( 'date_updated_gmt', 'total_amount' ),
'checksum_text_fields' => array( 'type', 'status' ),
'filter_values' => array(
'type' => array(
'operator' => 'IN',
'values' => WooCommerce_HPOS_Orders::get_order_types_to_sync( true ),
),
'status' => array(
'operator' => 'IN',
'values' => WooCommerce_HPOS_Orders::get_all_possible_order_status_keys(),
),
),
'is_table_enabled_callback' => 'Automattic\Jetpack\Sync\Replicastore\Table_Checksum::enable_woocommerce_hpos_tables',
),
'wc_order_addresses' => array(
'table' => "{$wpdb->prefix}wc_order_addresses",
'range_field' => 'order_id',
'key_fields' => array( 'order_id', 'address_type' ),
'checksum_text_fields' => array( 'address_type' ),
'parent_table' => 'wc_orders',
'parent_join_field' => 'id',
'table_join_field' => 'order_id',
'filter_values' => array(),
'is_table_enabled_callback' => array( $this, 'enable_woocommerce_tables' ),
'is_table_enabled_callback' => 'Automattic\Jetpack\Sync\Replicastore\Table_Checksum::enable_woocommerce_hpos_tables',
),
'wc_order_operational_data' => array(
'table' => "{$wpdb->prefix}wc_order_operational_data",
'range_field' => 'order_id',
'key_fields' => array( 'order_id' ),
'checksum_text_fields' => array( 'order_key', 'cart_hash' ),
'checksum_fields' => array( 'date_paid_gmt', 'date_completed_gmt' ),
'checksum_text_fields' => array( 'order_key' ),
'parent_table' => 'wc_orders',
'parent_join_field' => 'id',
'table_join_field' => 'order_id',
'filter_values' => array(),
'is_table_enabled_callback' => array( $this, 'enable_woocommerce_tables' ),
'is_table_enabled_callback' => 'Automattic\Jetpack\Sync\Replicastore\Table_Checksum::enable_woocommerce_hpos_tables',
),
'users' => array(
'table' => $wpdb->users,
@ -701,7 +719,7 @@ class Table_Checksum {
// The reason for this is that it leads to a non-performant query that can timeout.
// Instead lets get the range based on posts regardless of meta.
$filter_values = $this->filter_values;
if ( 'postmeta' === $this->table ) {
if ( $wpdb->postmeta === $this->table ) {
$this->filter_values = null;
}
@ -709,7 +727,7 @@ class Table_Checksum {
$filters = trim( $this->build_filter_statement( $range_from, $range_to ) );
// Reset Post meta filter.
if ( 'postmeta' === $this->table ) {
if ( $wpdb->postmeta === $this->table ) {
$this->filter_values = $filter_values;
}
@ -881,6 +899,37 @@ class Table_Checksum {
return true;
}
/**
* Make sure the WooCommerce HPOS tables should be enabled for Checksum/Fix.
*
* @see Automattic\Jetpack\SyncActions::initialize_woocommerce
*
* @since 3.3.0
*
* @return bool
*/
public static function enable_woocommerce_hpos_tables() {
/**
* On WordPress.com, we can't directly check if the site has support for WooCommerce HPOS tables.
* Having the option to override the functionality here helps with syncing WooCommerce HPOS tables.
*
* @since 3.3.0
*
* @param bool If we should we force-enable WooCommerce HPOS tables support.
*/
$force_woocommerce_hpos_support = apply_filters( 'jetpack_table_checksum_force_enable_woocommerce_hpos', false );
// If we're forcing WooCommerce HPOS tables support, there's no need to check further.
// This is used on WordPress.com.
if ( $force_woocommerce_hpos_support ) {
return true;
}
// If the 'woocommerce_hpos_orders' module is enabled, this means that WooCommerce class exists
// and HPOS is enabled too.
return false !== Sync\Modules::get_module( 'woocommerce_hpos_orders' );
}
/**
* Prepare and append custom columns to the list of columns that we run the checksum on.
*