Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove full sync legacy #39527

Draft
wants to merge 13 commits into
base: trunk
Choose a base branch
from
Draft
31 changes: 14 additions & 17 deletions projects/packages/sync/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
return [
// # Issue statistics:
// PhanTypeMismatchArgument : 35+ occurrences
// PhanTypeMismatchReturnProbablyReal : 35+ occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 30+ occurrences
// PhanTypeMismatchReturn : 20+ occurrences
// PhanPluginDuplicateConditionalNullCoalescing : 25+ occurrences
// PhanTypeMismatchReturnProbablyReal : 25+ occurrences
// PhanUndeclaredProperty : 20+ occurrences
// PhanParamSignatureMismatch : 15+ occurrences
// PhanTypeMismatchReturn : 15+ occurrences
// PhanParamSignatureMismatch : 10+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 10+ occurrences
// PhanPluginSimplifyExpressionBool : 9 occurrences
// PhanPossiblyUndeclaredVariable : 8 occurrences
// PhanPluginSimplifyExpressionBool : 7 occurrences
// PhanPluginDuplicateSwitchCaseLooseEquality : 6 occurrences
// PhanUndeclaredTypeReturnType : 6 occurrences
// PhanNonClassMethodCall : 5 occurrences
// PhanPossiblyUndeclaredVariable : 5 occurrences
// PhanRedundantCondition : 4 occurrences
// PhanTypeExpectedObjectPropAccess : 4 occurrences
// PhanTypeMismatchArgumentInternal : 4 occurrences
Expand All @@ -37,7 +38,6 @@
// PhanNoopNew : 1 occurrence
// PhanParamTooManyCallable : 1 occurrence
// PhanPluginUseReturnValueInternalKnown : 1 occurrence
// PhanTypeComparisonFromArray : 1 occurrence
// PhanTypeInvalidLeftOperandOfNumericOp : 1 occurrence
// PhanTypeMismatchArgumentNullableInternal : 1 occurrence
// PhanTypeMismatchDeclaredParam : 1 occurrence
Expand All @@ -61,25 +61,22 @@
'src/class-server.php' => ['PhanTypeMismatchDeclaredParam', 'PhanTypeMismatchReturnProbablyReal'],
'src/class-settings.php' => ['PhanNonClassMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'src/class-utils.php' => ['PhanTypeExpectedObjectPropAccess'],
'src/modules/class-callables.php' => ['PhanParamSignatureMismatch', 'PhanParamTooMany', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-comments.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-constants.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredProperty'],
'src/modules/class-callables.php' => ['PhanParamSignatureMismatch', 'PhanParamTooMany', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgument'],
'src/modules/class-comments.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-constants.php' => ['PhanParamSignatureMismatch', 'PhanUndeclaredProperty'],
'src/modules/class-full-sync-immediately.php' => ['PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchReturn'],
'src/modules/class-full-sync.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeComparisonFromArray'],
'src/modules/class-import.php' => ['PhanTypeMismatchArgumentInternal'],
'src/modules/class-meta.php' => ['PhanParamSignatureMismatch', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgumentProbablyReal'],
'src/modules/class-module.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-network-options.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-network-options.php' => ['PhanParamSignatureMismatch'],
'src/modules/class-options.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-plugins.php' => ['PhanPluginDuplicateConditionalNullCoalescing'],
'src/modules/class-posts.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginUseReturnValueInternalKnown', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-term-relationships.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument'],
'src/modules/class-terms.php' => ['PhanAccessMethodInternal', 'PhanParamSignatureMismatch'],
'src/modules/class-posts.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginUseReturnValueInternalKnown', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'src/modules/class-terms.php' => ['PhanAccessMethodInternal'],
'src/modules/class-themes.php' => ['PhanParamSignatureMismatch', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-updates.php' => ['PhanImpossibleCondition', 'PhanParamSignatureMismatch', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-updates.php' => ['PhanImpossibleCondition', 'PhanParamSignatureMismatch', 'PhanTypeMismatchReturn'],
'src/modules/class-users.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-woocommerce-hpos-orders.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'],
'src/modules/class-woocommerce.php' => ['PhanTypeMismatchReturnProbablyReal'],
'src/replicastore/class-table-checksum.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchPropertyProbablyReal'],
'tests/php/test-actions.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'tests/php/test-dedicated-sender.php' => ['PhanDeprecatedFunction', 'PhanUndeclaredProperty'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: removed

Sync: Remove Jetpack Full Sync Legacy
22 changes: 5 additions & 17 deletions projects/packages/sync/src/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,14 @@ public static function get_debug_details() {
// Sync locks.
$debug['debug_details']['dedicated_sync_enabled'] = Settings::is_dedicated_sync_enabled();

$queue = self::$sender->get_sync_queue();
$full_queue = self::$sender->get_full_sync_queue();
$queue = self::$sender->get_sync_queue();

$debug['debug_details']['sync_locks'] = array(
'retry_time_sync' => get_option( self::RETRY_AFTER_PREFIX . 'sync' ),
'retry_time_full_sync' => get_option( self::RETRY_AFTER_PREFIX . 'full_sync' ),
'next_sync_time_sync' => self::$sender->get_next_sync_time( 'sync' ),
'next_sync_time_full_sync' => self::$sender->get_next_sync_time( 'full_sync' ),
'queue_locked_sync' => $queue->is_locked(),
'queue_locked_full_sync' => $full_queue->is_locked(),
'dedicated_sync_request_lock' => \Jetpack_Options::get_raw_option( Dedicated_Sender::DEDICATED_SYNC_REQUEST_LOCK_OPTION_NAME, null ),
'dedicated_sync_temporary_disable_flag' => get_transient( Dedicated_Sender::DEDICATED_SYNC_TEMPORARY_DISABLE_FLAG ),
);
Expand Down Expand Up @@ -590,7 +588,7 @@ public static function do_initial_sync() {

// Don't start new sync if a full sync is in process.
$full_sync_module = Modules::get_module( 'full-sync' );
'@phan-var Modules\Full_Sync_Immediately|Modules\Full_Sync $full_sync_module';
'@phan-var Modules\Full_Sync_Immediately $full_sync_module';
if ( $full_sync_module && $full_sync_module->is_started() && ! $full_sync_module->is_finished() ) {
return false;
}
Expand All @@ -613,7 +611,7 @@ public static function do_initial_sync() {
*/
public static function do_only_first_initial_sync() {
$full_sync_module = Modules::get_module( 'full-sync' );
'@phan-var Modules\Full_Sync_Immediately|Modules\Full_Sync $full_sync_module';
'@phan-var Modules\Full_Sync_Immediately $full_sync_module';
if ( $full_sync_module && $full_sync_module->is_started() ) {
return false;
}
Expand All @@ -636,7 +634,7 @@ public static function do_full_sync( $modules = null ) {
}

$full_sync_module = Modules::get_module( 'full-sync' );
'@phan-var Modules\Full_Sync_Immediately|Modules\Full_Sync $full_sync_module';
'@phan-var Modules\Full_Sync_Immediately $full_sync_module';

if ( ! $full_sync_module ) {
return false;
Expand Down Expand Up @@ -1045,7 +1043,7 @@ public static function get_sync_status( $fields = null ) {
self::initialize_sender();

$sync_module = Modules::get_module( 'full-sync' );
'@phan-var Modules\Full_Sync_Immediately|Modules\Full_Sync $sync_module';
'@phan-var Modules\Full_Sync_Immediately $sync_module';
$queue = self::$sender->get_sync_queue();

// _get_cron_array can be false
Expand Down Expand Up @@ -1079,8 +1077,6 @@ public static function get_sync_status( $fields = null ) {

$full_sync_status = ( $sync_module ) ? $sync_module->get_status() : array();

$full_queue = self::$sender->get_full_sync_queue();

$result = array_merge(
$full_sync_status,
$checksums,
Expand All @@ -1095,11 +1091,6 @@ public static function get_sync_status( $fields = null ) {
)
);

// Verify $sync_module is not false.
if ( $sync_module && ! $sync_module instanceof Modules\Full_Sync_Immediately ) {
$result['full_queue_size'] = $full_queue->size();
$result['full_queue_lag'] = $full_queue->lag();
}
return $result;
}

Expand Down Expand Up @@ -1131,9 +1122,6 @@ public static function reset_sync_locks( $unlock_queues = true ) {
if ( $unlock_queues ) {
$sync_queue = new Queue( 'sync' );
$sync_queue->unlock();

$full_sync_queue = new Queue( 'full_sync' );
$full_sync_queue->unlock();
}
}

Expand Down
90 changes: 2 additions & 88 deletions projects/packages/sync/src/class-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ class Listener {
*/
private $sync_queue;

/**
* Full sync queue.
*
* @var object
*/
private $full_sync_queue;

/**
* Sync queue size limit.
*
Expand Down Expand Up @@ -80,12 +73,10 @@ protected function __construct() {
* Sync Listener init.
*/
private function init() {
$handler = array( $this, 'action_handler' );
$full_sync_handler = array( $this, 'full_sync_action_handler' );
$handler = array( $this, 'action_handler' );

foreach ( Modules::get_modules() as $module ) {
$module->init_listeners( $handler );
$module->init_full_sync_listeners( $full_sync_handler );
}

// Module Activation.
Expand All @@ -106,13 +97,6 @@ public function get_sync_queue() {
return $this->sync_queue;
}

/**
* Gets the full sync queue.
*/
public function get_full_sync_queue() {
return $this->full_sync_queue;
}

/**
* Sets queue size limit.
*
Expand Down Expand Up @@ -150,7 +134,6 @@ public function get_queue_lag_limit() {
*/
public function force_recheck_queue_limit() {
delete_transient( self::QUEUE_STATE_CHECK_TRANSIENT . '_' . $this->sync_queue->id );
delete_transient( self::QUEUE_STATE_CHECK_TRANSIENT . '_' . $this->full_sync_queue->id );
}

/**
Expand Down Expand Up @@ -183,15 +166,6 @@ public function can_add_to_queue( $queue ) {
( ( $queue_size + 1 ) < $this->sync_queue_size_limit );
}

/**
* Full sync action handler.
*
* @param mixed ...$args Args passed to the action.
*/
public function full_sync_action_handler( ...$args ) {
$this->enqueue_action( current_filter(), $args, $this->full_sync_queue );
}

/**
* Action handler.
*
Expand All @@ -203,65 +177,6 @@ public function action_handler( ...$args ) {

// add many actions to the queue directly, without invoking them.

/**
* Bulk add action to the queue.
*
* @param string $action_name The name the full sync action.
* @param array $args_array Array of chunked arguments.
*/
public function bulk_enqueue_full_sync_actions( $action_name, $args_array ) {
$queue = $this->get_full_sync_queue();

/*
* If we add any items to the queue, we should try to ensure that our script
* can't be killed before they are sent.
*/
// https://plugins.trac.wordpress.org/ticket/2041
if ( function_exists( 'ignore_user_abort' ) ) {
ignore_user_abort( true );
}

$data_to_enqueue = array();
$user_id = get_current_user_id();
$currtime = microtime( true );
$is_importing = Settings::is_importing();

foreach ( $args_array as $args ) {
$previous_end = isset( $args['previous_end'] ) ? $args['previous_end'] : null;
$args = isset( $args['ids'] ) ? $args['ids'] : $args;

/**
* Modify or reject the data within an action before it is enqueued locally.
*
* @since 1.6.3
* @since-jetpack 4.2.0
*
* @module sync
*
* @param array The action parameters
*/
$args = apply_filters( "jetpack_sync_before_enqueue_$action_name", $args );
$action_data = array( $args );
if ( $previous_end !== null ) {
$action_data[] = $previous_end;
}
// allow listeners to abort.
if ( false === $args ) {
continue;
}

$data_to_enqueue[] = array(
$action_name,
$action_data,
$user_id,
$currtime,
$is_importing,
);
}

$queue->add_all( $data_to_enqueue );
}

/**
* Enqueue the action.
*
Expand Down Expand Up @@ -464,8 +379,7 @@ public function should_send_user_data_with_actor( $current_filter ) {
* Sets Listener defaults.
*/
public function set_defaults() {
$this->sync_queue = new Queue( 'sync' );
$this->full_sync_queue = new Queue( 'full_sync' );
$this->sync_queue = new Queue( 'sync' );
$this->set_queue_size_limit( Settings::get_setting( 'max_queue_size' ) );
$this->set_queue_lag_limit( Settings::get_setting( 'max_queue_lag' ) );
}
Expand Down
9 changes: 0 additions & 9 deletions projects/packages/sync/src/class-rest-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,15 +693,6 @@ public static function close( $request ) {

$queue = new Queue( $queue_name );

$items = $queue->peek_by_id( $request_body['item_ids'] );

// Update Full Sync Status if queue is "full_sync".
if ( 'full_sync' === $queue_name ) {
$full_sync_module = Modules::get_module( 'full-sync' );
'@phan-var Modules\Full_Sync_Immediately|Modules\Full_Sync $full_sync_module';
$full_sync_module->update_sent_progress_action( $items );
}

$buffer = new Queue_Buffer( $request_body['buffer_id'], $request_body['item_ids'] );
$response = $queue->close( $buffer, $request_body['item_ids'] );

Expand Down
Loading
Loading