updated plugin Jetpack Protect version 1.3.0

This commit is contained in:
2023-03-17 22:34:13 +00:00
committed by Gitium
parent 19e086d1c4
commit 1e9ac45ec6
183 changed files with 4388 additions and 2345 deletions

View File

@ -5,6 +5,44 @@ 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).
## [1.47.2] - 2023-02-20
### Changed
- Minor internal updates.
## [1.47.1] - 2023-01-23
### Added
- Close PHP Session if it's active when running a Dedicated Sync request. [#28515]
### Fixed
- Jetpack Sync: prevent syncing user update when corresponding flags are not set. [#28385]
## [1.47.0] - 2023-01-18
### Removed
- Removed the deprecated option jetpack_blogging_prompts_enabled from defaults [#28387]
## [1.46.1] - 2023-01-11
### Changed
- Updated package dependencies.
## [1.46.0] - 2022-12-27
### Added
- Added woocommerce_cod_settings to the options whitelist. [#27988]
## [1.45.0] - 2022-12-19
### Added
- Adding new boolean site option of 'wpcom-subscription-emails-use-excerpt'. [#27908]
- Sync Launchpad-related options: `launchpad_screen` and `launchpad_checklist_tasks_statuses`. [#27843]
### Changed
- Option: Update featured_image_email_enabled option name to wpcom_featured_image_in_email. [#27955]
### Fixed
- Improve PHP 8.2 compatibility. [#27968]
## [1.44.2] - 2022-12-06
### Changed
- Updated package dependencies.
## [1.44.1] - 2022-12-02
### Changed
- Updated package dependencies. [#27688]
@ -780,6 +818,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Packages: Move sync to a classmapped package
[1.47.2]: https://github.com/Automattic/jetpack-sync/compare/v1.47.1...v1.47.2
[1.47.1]: https://github.com/Automattic/jetpack-sync/compare/v1.47.0...v1.47.1
[1.47.0]: https://github.com/Automattic/jetpack-sync/compare/v1.46.1...v1.47.0
[1.46.1]: https://github.com/Automattic/jetpack-sync/compare/v1.46.0...v1.46.1
[1.46.0]: https://github.com/Automattic/jetpack-sync/compare/v1.45.0...v1.46.0
[1.45.0]: https://github.com/Automattic/jetpack-sync/compare/v1.44.2...v1.45.0
[1.44.2]: https://github.com/Automattic/jetpack-sync/compare/v1.44.1...v1.44.2
[1.44.1]: https://github.com/Automattic/jetpack-sync/compare/v1.44.0...v1.44.1
[1.44.0]: https://github.com/Automattic/jetpack-sync/compare/v1.43.2...v1.44.0
[1.43.2]: https://github.com/Automattic/jetpack-sync/compare/v1.43.1...v1.43.2

View File

@ -4,15 +4,15 @@
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-connection": "^1.47.1",
"automattic/jetpack-constants": "^1.6.20",
"automattic/jetpack-identity-crisis": "^0.8.33",
"automattic/jetpack-password-checker": "^0.2.9",
"automattic/jetpack-roles": "^1.4.19",
"automattic/jetpack-status": "^1.15.2"
"automattic/jetpack-connection": "^1.51.0",
"automattic/jetpack-constants": "^1.6.21",
"automattic/jetpack-identity-crisis": "^0.8.38",
"automattic/jetpack-password-checker": "^0.2.11",
"automattic/jetpack-roles": "^1.4.22",
"automattic/jetpack-status": "^1.16.2"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.2.2",
"automattic/jetpack-changelogger": "^3.3.2",
"yoast/phpunit-polyfills": "1.0.4",
"automattic/wordbless": "@dev"
},
@ -25,9 +25,6 @@
"phpunit": [
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-coverage": [
"php -dpcov.directory=. ./vendor/bin/phpunit --coverage-clover \"$COVERAGE_DIR/clover.xml\""
],
"test-php": [
"@composer phpunit"
],
@ -47,7 +44,7 @@
"link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "1.44.x-dev"
"dev-trunk": "1.47.x-dev"
}
},
"config": {

View File

@ -370,7 +370,6 @@ class Actions {
$debug['debug_details']['sync_error_log'] = get_option( self::ERROR_LOG_PREFIX . 'sync', '' );
return $debug;
}
/**
@ -705,7 +704,7 @@ class Actions {
$result = 'full_sync' === $type ? self::$sender->do_full_sync() : self::$sender->do_sync();
// # of send actions performed.
$executions ++;
++$executions;
} while ( $result && ! is_wp_error( $result ) && ( $start_time + $time_limit ) > time() );

View File

@ -57,7 +57,6 @@ class Defaults {
'disabled_reblogs',
'disallowed_keys',
'enable_header_ad',
'featured_image_email_enabled',
'gmt_offset',
'gravatar_disable_hovercards',
'highlander_comment_form_prompt',
@ -103,6 +102,8 @@ class Defaults {
'large_size_h',
'large_size_w',
'launch-status',
'launchpad_checklist_tasks_statuses',
'launchpad_screen',
'mailserver_login', // Not syncing contents, only the option name.
'mailserver_pass', // Not syncing contents, only the option name.
'mailserver_port',
@ -171,9 +172,11 @@ class Defaults {
'wp_mobile_excerpt',
'wp_mobile_featured_images',
'wp_page_for_privacy_policy',
'wpcom_featured_image_in_email',
'wpcom_is_fse_activated',
'wpcom_publish_comments_with_markdown',
'wpcom_publish_posts_with_markdown',
'wpcom_subscription_emails_use_excerpt',
'videopress_private_enabled_for_site',
'wpcom_gifting_subscription',
);

View File

@ -627,7 +627,6 @@ class Functions {
}
return $any;
}
/**

View File

@ -79,7 +79,7 @@ class Health {
* If sync is active, Health-related hooks will be initialized after plugins are loaded.
*/
public static function init() {
add_action( 'jetpack_full_sync_end', array( __ClASS__, 'full_sync_end_update_status' ), 10, 2 );
add_action( 'jetpack_full_sync_end', array( __CLASS__, 'full_sync_end_update_status' ), 10, 2 );
}
/**
@ -102,7 +102,6 @@ class Health {
default:
return self::STATUS_UNKNOWN;
}
}
/**

View File

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

View File

@ -22,6 +22,7 @@ class Queue {
* @var string
*/
public $id;
/**
* Keeps track of the rows.
*
@ -29,6 +30,13 @@ class Queue {
*/
private $row_iterator;
/**
* Random number.
*
* @var int
*/
public $random_int;
/**
* Queue constructor.
*
@ -611,7 +619,6 @@ class Queue {
$this->get_lock_option_name()
)
);
}
/**
@ -671,7 +678,6 @@ class Queue {
}
return $this->unserialize_values( $items );
}
/**
@ -722,7 +728,6 @@ class Queue {
);
return $items;
}
/**

View File

@ -327,7 +327,6 @@ class REST_Endpoints {
'permission_callback' => __CLASS__ . '::verify_default_permissions',
)
);
}
/**
@ -701,11 +700,9 @@ class REST_Endpoints {
if ( in_array( $queue_name, array( 'full_sync', 'immediate' ), true ) ) {
// Send Full Sync Actions.
Sender::get_instance()->do_full_sync();
} else {
} elseif ( $queue->has_any_items() ) {
// Send Incremental Sync Actions.
if ( $queue->has_any_items() ) {
Sender::get_instance()->do_sync();
}
Sender::get_instance()->do_sync();
}
}

View File

@ -379,6 +379,24 @@ class Sender {
// Try to disconnect the request as quickly as possible and process things in the background.
$this->fastcgi_finish_request();
/**
* Close the PHP session to free up the server threads to handle other requests while we
* send sync data with Dedicated Sync.
*
* When we spawn Dedicated Sync, we send `$_COOKIES` with the request to help out with any
* firewall and/or caching functionality that might prevent us to ping the site directly.
*
* This will cause Dedicated Sync to reuse the visitor's PHP session and lock it until the
* request finishes, which can take anywhere from 1 to 30+ seconds, depending on the server
* `max_execution_time` configuration.
*
* By closing the session we're freeing up the session, so other requests can acquire the
* lock and proceed with their own tasks.
*/
if ( session_status() === PHP_SESSION_ACTIVE ) {
session_write_close();
}
// Output not used right now. Try to release dedicated sync lock
Dedicated_Sender::try_release_lock_spawn_request();

View File

@ -395,7 +395,7 @@ class Callables extends Module {
// The @ is not enough to suppress errors when dealing with libxml,
// we have to tell it directly how we want to handle errors.
libxml_use_internal_errors( true );
$dom_doc->loadHTML( mb_convert_encoding( $action_link, 'HTML-ENTITIES', 'UTF-8' ) );
$dom_doc->loadHTML( '<?xml encoding="utf-8" ?>' . $action_link );
libxml_use_internal_errors( false );
$link_elements = $dom_doc->getElementsByTagName( 'a' );

View File

@ -270,7 +270,7 @@ abstract class Module {
$listener->bulk_enqueue_full_sync_actions( $action_name, $chunked_ids_with_previous_end );
$chunk_count += count( $chunked_ids );
$page++;
++$page;
// The $ids are ordered in descending order.
$previous_interval_end = end( $ids );
}

View File

@ -332,16 +332,17 @@ class Plugins extends Module {
$real_file = WP_PLUGIN_DIR . '/' . $file;
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable
if ( ! is_writeable( $real_file ) ) {
return;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
$file_pointer = fopen( $real_file, 'w+' );
if ( false === $file_pointer ) {
return;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
fclose( $file_pointer );
/**
* This action is documented already in this file

View File

@ -81,7 +81,6 @@ class Search extends Module {
'jetpack-search-meta9' => array( 'searchable_in_all_content' => true ),
// woocommerce.
'entity_types' => array(),
'exclude_product_categories' => array(),
'exclude_product_ids' => array(),
'free_shipping' => array(),
@ -468,7 +467,6 @@ class Search extends Module {
'_manage_stock' => array(),
'_product_image_gallery' => array(),
'_purchase_note' => array(),
'_recorded_coupon_usage_counts' => array(),
'_recorded_sales' => array(),
'_sold_individually' => array(),
'_stock' => array(),
@ -656,7 +654,6 @@ class Search extends Module {
'_VenueVenue' => array(),
'_VenueVenueID' => array(),
'_VenueZip' => array(),
'_default_attributes' => array(),
'_description' => array(),
'_edit_last' => array(),
'_feedback_all_fields' => array(),
@ -666,7 +663,6 @@ class Search extends Module {
'_feedback_contact_form_url' => array(),
'_feedback_ip' => array(),
'_feedback_subject' => array(),
'_file_paths' => array(),
'_layout' => array(),
'_links_to' => array(),
'_links_to_target' => array(),

View File

@ -307,16 +307,17 @@ class Themes extends Module {
}
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_is_writeable
if ( ! is_writeable( $real_file ) ) {
return;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fopen
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
$file_pointer = fopen( $real_file, 'w+' );
if ( false === $file_pointer ) {
return;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
fclose( $file_pointer );
$theme_data = array(
@ -677,7 +678,6 @@ class Themes extends Module {
}
}
return $moved_to_inactive;
}
/**
@ -715,7 +715,6 @@ class Themes extends Module {
*/
do_action( 'jetpack_widget_reordered', $sidebar, $sidebar_name );
}
}
/**

View File

@ -107,7 +107,6 @@ class Updates extends Module {
add_action( 'jetpack_sync_core_reinstalled_successfully', $callable );
add_action( 'jetpack_sync_core_autoupdated_successfully', $callable, 10, 2 );
add_action( 'jetpack_sync_core_updated_successfully', $callable, 10, 2 );
}
/**
@ -352,7 +351,6 @@ class Updates extends Module {
*/
do_action( "jetpack_{$transient}_change", $value );
}
}
/**

View File

@ -31,6 +31,21 @@ class Users extends Module {
*/
protected $flags = array();
/**
* Mapping between user fields to flags.
*
* @var array
*/
protected $user_fields_to_flags_mapping = array(
'user_pass' => 'password_changed',
'user_email' => 'email_changed',
'user_nicename' => 'nicename_changed',
'user_url' => 'url_changed',
'user_registered' => 'registration_date_changed',
'user_activation_key' => 'activation_key_changed',
'display_name' => 'display_name_changed',
);
/**
* Sync module name.
*
@ -433,7 +448,6 @@ class Users extends Module {
*/
do_action( 'jetpack_sync_register_user', $user_id, $this->get_flags( $user_id ) );
$this->clear_flags( $user_id );
}
/**
@ -488,31 +502,49 @@ class Users extends Module {
$old_user = $old_user_data;
}
if ( null !== $old_user && $user->user_pass !== $old_user->user_pass ) {
$this->flags[ $user_id ]['password_changed'] = true;
if ( ! is_object( $old_user ) ) {
return;
}
if ( null !== $old_user && $user->data->user_email !== $old_user->user_email ) {
/**
* The '_new_email' user meta is deleted right after the call to wp_update_user
* that got us to this point so if it's still set then this was a user confirming
* their new email address.
*/
if ( 1 === (int) get_user_meta( $user->ID, '_new_email', true ) ) {
$this->flags[ $user_id ]['email_changed'] = true;
$old_user_array = get_object_vars( $old_user );
foreach ( $old_user_array as $user_field => $field_value ) {
if ( false === $user->has_prop( $user_field ) ) {
continue;
}
if ( $user->$user_field !== $field_value ) {
if ( 'user_email' === $user_field ) {
/**
* The '_new_email' user meta is deleted right after the call to wp_update_user
* that got us to this point so if it's still set then this was a user confirming
* their new email address.
*/
if ( 1 === (int) get_user_meta( $user->ID, '_new_email', true ) ) {
$this->flags[ $user_id ]['email_changed'] = true;
}
continue;
}
$flag = isset( $this->user_fields_to_flags_mapping[ $user_field ] ) ? $this->user_fields_to_flags_mapping[ $user_field ] : 'unknown_field_changed';
$this->flags[ $user_id ][ $flag ] = true;
}
}
/**
* Fires when the client needs to sync an updated user.
*
* @since 1.6.3
* @since-jetpack 4.2.0
*
* @param \WP_User The WP_User object
* @param array State - New since 5.8.0
*/
do_action( 'jetpack_sync_save_user', $user_id, $this->get_flags( $user_id ) );
$this->clear_flags( $user_id );
if ( isset( $this->flags[ $user_id ] ) ) {
/**
* Fires when the client needs to sync an updated user.
*
* @since 1.6.3
* @since-jetpack 4.2.0
*
* @param \WP_User The WP_User object
* @param array State - New since 5.8.0
*/
do_action( 'jetpack_sync_save_user', $user_id, $this->get_flags( $user_id ) );
$this->clear_flags( $user_id );
}
}
/**

View File

@ -406,6 +406,7 @@ class WooCommerce extends Module {
'woocommerce_allow_tracking',
'woocommerce_task_list_hidden',
'woocommerce_onboarding_profile',
'woocommerce_cod_settings',
);
/**