Skip to content

Commit

Permalink
Jetpack Sync: Ensure Full Sync is only triggered on backend admin POS…
Browse files Browse the repository at this point in the history
…T requests (#39747)

* Jetpack Sync: Ensure Full Sync is only triggered on backend admin POST requests

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

Upstream-Ref: Automattic/jetpack@38caf5c
  • Loading branch information
fgiannar authored and matticbot committed Oct 14, 2024
1 parent 0401ac4 commit 74bd22e
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 121 deletions.
3 changes: 3 additions & 0 deletions jetpack_vendor/automattic/jetpack-sync/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

### Fixed
- Jetpack Sync: Ensure Full Sync is only triggered on backend admin POST requests

## [3.14.0] - 2024-10-10
### Added
- Jetpack Sync: Add 'woocommerce_analytics_first_activation' in options' whitelist
Expand Down
13 changes: 9 additions & 4 deletions jetpack_vendor/automattic/jetpack-sync/src/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public static function add_sender_shutdown() {
) ) {
self::initialize_sender();
add_action( 'shutdown', array( self::$sender, 'do_sync' ), 9998 );
add_action( 'shutdown', array( self::$sender, 'do_full_sync' ), 9999 );
if ( self::should_initialize_sender( true ) ) {
add_action( 'shutdown', array( self::$sender, 'do_full_sync' ), 9999 );
}
}
}

Expand Down Expand Up @@ -212,9 +214,11 @@ public static function mark_sync_read_only() {
* @access public
* @static
*
* @param bool $full_sync Whether the Full Sync sender should run on shutdown for this request.
*
* @return bool
*/
public static function should_initialize_sender() {
public static function should_initialize_sender( $full_sync = false ) {

// Allow for explicit disable of Sync from request param jetpack_sync_read_only.
if ( isset( $_REQUEST['jetpack_sync_read_only'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
Expand All @@ -227,9 +231,10 @@ public static function should_initialize_sender() {
}

/**
* For now, if dedicated Sync is enabled we will always initialize send, even for GET and unauthenticated requests.
* For now, if dedicated Sync is enabled we will always initialize send, even for GET and unauthenticated requests
* but not for Full Sync, since it will still happen on shutdown.
*/
if ( Settings::is_dedicated_sync_enabled() ) {
if ( false === $full_sync && Settings::is_dedicated_sync_enabled() ) {
return true;
}

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 @@ -70,7 +70,7 @@
),
'jetpack-sync' => array(
'path' => 'jetpack_vendor/automattic/jetpack-sync',
'ver' => '3.14.1-alpha1728625192',
'ver' => '3.14.1-alpha1728893254',
),
),
);
60 changes: 30 additions & 30 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-a8c-mc-stats",
"reference": "a3aa5b3d1314202df93cadabd929e5465ccaff9a"
"reference": "c6997c1cbf168b0b8cb37ba880314c0830af29d8"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -60,7 +60,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-admin-ui",
"reference": "8d5159c23bae59b609495cf0876ba7d45a8d1d5a"
"reference": "d130eacc03f1de8e2f02e1f4fe9be14160ef995e"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -125,7 +125,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-assets",
"reference": "1f17dc4d3a786297753122651ce36c5eb3892c46"
"reference": "365539b68af45d782b67d455dea267d61a1c42d1"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -194,7 +194,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-autoloader",
"reference": "cf10281e5cb65426fefce4adcbe5de04768c96ba"
"reference": "1a1951b5529d957bd4eaaa8e2a53b408958b6b5c"
},
"require": {
"composer-plugin-api": "^1.1 || ^2.0",
Expand Down Expand Up @@ -261,7 +261,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-backup",
"reference": "52b2dd59e85b58f66184fb103eaa0c86a567b3ea"
"reference": "69c5168f38aa27974be306e0595b890cd0dab7be"
},
"require": {
"automattic/jetpack-admin-ui": "^0.4.5",
Expand Down Expand Up @@ -351,7 +351,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-backup-helper-script-manager",
"reference": "a835c5b6a731d83eeb6e90da3e70baeba35e6789"
"reference": "14ed5a47b34e15e993f8c8278438f964b73c9dcb"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -411,7 +411,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-boost-core",
"reference": "726976ac37ce251a53a9846a23ad353171cb12fa"
"reference": "94509a94aad02f8024dd55249a6dc459e06c94fc"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down Expand Up @@ -479,7 +479,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-boost-speed-score",
"reference": "c792992e6867389ec9d3513dfa118b28efdb3933"
"reference": "c0dda9fc715e387d1409d40f08cc633a68cebb65"
},
"require": {
"automattic/jetpack-boost-core": "^0.2.12",
Expand Down Expand Up @@ -555,7 +555,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-composer-plugin",
"reference": "c772f5af9d04c93bc7f24d8b980b577706ab1cb5"
"reference": "c843b0392080da6fd2a69d982a5456e65b920bc1"
},
"require": {
"composer-plugin-api": "^2.1.0",
Expand Down Expand Up @@ -615,7 +615,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-config",
"reference": "0971ba8b0a0522c9fb17f20ffbcdbed7285649ee"
"reference": "65a1010ee106d3788562aa982964957f2f0eec95"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -690,7 +690,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-connection",
"reference": "498b467efd61f13f9abd015a42b47cf4340d36fd"
"reference": "37afc9d8e4933595c93112a22b58cfe649539b15"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -780,7 +780,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-constants",
"reference": "78a99209bb2f70f0f9fa7f6fa3a9a4ace81abfb3"
"reference": "d94536d238507aa2062922748561f0cbaee4ce31"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -834,7 +834,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "5166ae5c506a25e2fc8b494b4e947577682aab29"
"reference": "dcb146c324eb0b42e81f4dc14cebe16149c17db5"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -887,7 +887,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-explat",
"reference": "4c45f6e7cc62b190e12be91d3f782048645ee691"
"reference": "f8bc9a997e344a86057700cc5413467f830671db"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down Expand Up @@ -962,7 +962,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-ip",
"reference": "0693dafafda797b162f8cc12af7975af4f34d43f"
"reference": "5a5fcf6a1777b0ad2fdf1a39161f958aec3b6bd1"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1020,7 +1020,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-jitm",
"reference": "e6ddc934baa87cab856ca268d635f1d49a645ae7"
"reference": "29ff111b230dad6aa975eb4ced7e4732f475585b"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -1095,7 +1095,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-licensing",
"reference": "b170b001b34de35374bdca3ed4c0819852af6e8a"
"reference": "cbcd48c815b0abbc5e3277a92d6cfe1dc5009d7b"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down Expand Up @@ -1157,7 +1157,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-logo",
"reference": "a4e8d11c5fd03d541f7b6ada9b27a9e40b36b30c"
"reference": "d56deaef2e83e660a01c7c68432f4264321a5e56"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1210,7 +1210,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-my-jetpack",
"reference": "9f3be90c214c6a66e99b8e06c72d897ea09282b7"
"reference": "0a06e33eda3da0b91fdf54c2e0561072daa40984"
},
"require": {
"automattic/jetpack-admin-ui": "^0.4.5",
Expand Down Expand Up @@ -1312,7 +1312,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-password-checker",
"reference": "6947da6b7b86bb2d0c47fe24c0aa773f6c188584"
"reference": "e6ea57a292445a348f5486d4d0c129ff423645bc"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1373,7 +1373,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plans",
"reference": "8bc3a01221cca6cb110c74ad5fdb9273aef2c5df"
"reference": "dd36a829a01a479a6a3f04c8a02617ff323803bc"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down Expand Up @@ -1441,7 +1441,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plugins-installer",
"reference": "afdaf7d0e3daa3a7350cc15dbf6022e72ed01fe1"
"reference": "565c0a013b47d1ca5e1c7c5fa2c7ed58c1588a8f"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -1497,7 +1497,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-protect-models",
"reference": "0bce1b9dc9f5f6ccc4c6031f6f8724d4d3f8e320"
"reference": "9607cddd10c07721aa303a208e9603b75ed4ecc5"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1567,7 +1567,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-protect-status",
"reference": "c7e10d8c95cacf55663a01b9b6aad90dbb1de921"
"reference": "02a88e4638da7964e7edefd4d9c58f3eca2f681b"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down Expand Up @@ -1642,7 +1642,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-redirect",
"reference": "4d7edd095f258167ca9a42966d1d91ac2ba88e15"
"reference": "ee10254152ac4f183818ed22ea5673b8c9535b33"
},
"require": {
"automattic/jetpack-status": "^4.0.2",
Expand Down Expand Up @@ -1697,7 +1697,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-roles",
"reference": "7fb40c18c47cc37508ae16325403d2d456920e84"
"reference": "2b3342235040aef190d4add9703419daace856dd"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1751,7 +1751,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-status",
"reference": "05ddd259e1e70c4badf60c66e68942e51c6665a8"
"reference": "f16afbb91247e5a89bf068a784fe08df60bf31d3"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -1810,12 +1810,12 @@
},
{
"name": "automattic/jetpack-sync",
"version": "3.14.1-alpha.1728625192",
"version_normalized": "3.14.1.0-alpha1728625192",
"version": "3.14.1-alpha.1728893254",
"version_normalized": "3.14.1.0-alpha1728893254",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-sync",
"reference": "bf57be904f5a114baf8660f9b0511303de67ce79"
"reference": "0f99cf30797b2b6cbb3b039f7345b411cd86c482"
},
"require": {
"automattic/jetpack-connection": "^5.1.3",
Expand Down
Loading

0 comments on commit 74bd22e

Please sign in to comment.