Skip to content

Commit

Permalink
Full sync config modules order dictates order of execution (#40100)
Browse files Browse the repository at this point in the history
* Updated remaining modules code to return the modules based on full sync config order

* Added test

* changelog

* Phan

* Updated defaults to have order as before

* Wrong auto fixes

* Used array_keys to make phan happy

* Phan changes

* Update to have constants options and callables first

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11742882006

Upstream-Ref: Automattic/jetpack@076ee8e
  • Loading branch information
darssen authored and matticbot committed Nov 8, 2024
1 parent 71e8112 commit 77742b4
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 153 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"automattic/jetpack-config": "^2.0.4",
"automattic/jetpack-connection": "^5.1.7-alpha",
"automattic/jetpack-my-jetpack": "^4.37.0-alpha",
"automattic/jetpack-sync": "^3.14.5-alpha",
"automattic/jetpack-sync": "^3.15.0-alpha",
"automattic/jetpack-status": "^4.0.3"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-my-jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"automattic/jetpack-constants": "^2.0.5",
"automattic/jetpack-plans": "^0.4.13",
"automattic/jetpack-status": "^4.0.3",
"automattic/jetpack-sync": "^3.14.5-alpha",
"automattic/jetpack-sync": "^3.15.0-alpha",
"automattic/jetpack-protect-status": "^0.2.2"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"php": ">=7.0",
"automattic/jetpack-connection": "^5.1.7-alpha",
"automattic/jetpack-plugins-installer": "^0.4.4",
"automattic/jetpack-sync": "^3.14.5-alpha",
"automattic/jetpack-sync": "^3.15.0-alpha",
"automattic/jetpack-protect-models": "^0.3.1",
"automattic/jetpack-plans": "^0.4.13"
},
Expand Down
7 changes: 5 additions & 2 deletions jetpack_vendor/automattic/jetpack-sync/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ 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.14.5-alpha] - unreleased
## [3.15.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Changed
- Sync: Modules in Full Sync are now sent in the order the config is set.

### Fixed
- Jetpack Sync: Add missing handlers for removing or trashing shop_subscription orders

Expand Down Expand Up @@ -1333,7 +1336,7 @@ This is an alpha version! The changes listed here are not final.

- Packages: Move sync to a classmapped package

[3.14.5-alpha]: https://github.com/Automattic/jetpack-sync/compare/v3.14.4...v3.14.5-alpha
[3.15.0-alpha]: https://github.com/Automattic/jetpack-sync/compare/v3.14.4...v3.15.0-alpha
[3.14.4]: https://github.com/Automattic/jetpack-sync/compare/v3.14.3...v3.14.4
[3.14.3]: https://github.com/Automattic/jetpack-sync/compare/v3.14.2...v3.14.3
[3.14.2]: https://github.com/Automattic/jetpack-sync/compare/v3.14.1...v3.14.2
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/automattic/jetpack-sync/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "3.14.x-dev"
"dev-trunk": "3.15.x-dev"
},
"dependencies": {
"test-only": [
Expand Down
8 changes: 4 additions & 4 deletions jetpack_vendor/automattic/jetpack-sync/src/class-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -1295,16 +1295,16 @@ public static function is_multi_network() {
* @var array list of module names.
*/
public static $default_full_sync_config = array(
'comments' => 1,
'constants' => 1,
'functions' => 1,
'options' => 1,
'posts' => 1,
'term_relationships' => 1,
'terms' => 1,
'themes' => 1,
'updates' => 1,
'users' => 1,
'posts' => 1,
'comments' => 1,
'updates' => 1,
'term_relationships' => 1,
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Package_Version {

const PACKAGE_VERSION = '3.14.5-alpha';
const PACKAGE_VERSION = '3.15.0-alpha';

const PACKAGE_SLUG = 'sync';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,33 +414,25 @@ public function send() {
* @return array
*/
public function get_remaining_modules_to_send() {
$status = $this->get_status();

return array_filter(
Modules::get_modules(),
/**
* Select configured and not finished modules.
*
* @param Module $module
* @return bool
*/
function ( $module ) use ( $status ) {
// Skip module if not configured for this sync or module is done.
if ( ! isset( $status['config'][ $module->name() ] ) ) {
return false;
}
if ( ! $status['config'][ $module->name() ] ) {
return false;
}
if ( isset( $status['progress'][ $module->name() ]['finished'] ) ) {
if ( true === $status['progress'][ $module->name() ]['finished'] ) {
return false;
}
}

return true;
$status = $this->get_status();
$remaining_modules = array();
foreach ( array_keys( $status['config'] ) as $module_name ) {
$module = Modules::get_module( $module_name );
if ( ! $module ) {
continue;
}
);
if ( isset( $status['progress'][ $module_name ]['finished'] ) &&
true === $status['progress'][ $module_name ]['finished'] ) {
continue;
}
// Ensure that 'constants', 'options', and 'callables' are sent first.
if ( in_array( $module_name, array( 'network_options', 'options', 'functions', 'constants' ), true ) ) {
array_unshift( $remaining_modules, $module );
} else {
$remaining_modules[] = $module;
}
}
return $remaining_modules;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion jetpack_vendor/i18n-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
),
'jetpack-sync' => array(
'path' => 'jetpack_vendor/automattic/jetpack-sync',
'ver' => '3.14.5-alpha1730811047',
'ver' => '3.15.0-alpha1731071952',
),
),
);
Loading

0 comments on commit 77742b4

Please sign in to comment.