Skip to content

Commit

Permalink
Sync: Don't sync set object terms action for blacklisted taxonomies (…
Browse files Browse the repository at this point in the history
…#39663)

* Filter out set_object_terms actions with blacklisted taxonomies

* Args in this flow does not have the terms retrieved as objects. Instead we rely directly on the taxonomy

* changelog

* Update projects/packages/sync/src/modules/class-terms.php

Co-authored-by: Foteini Giannaropoulou <giannaropoulou.foteini@gmail.com>

---------

Co-authored-by: Foteini Giannaropoulou <giannaropoulou.foteini@gmail.com>

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

Upstream-Ref: Automattic/jetpack@70eae9f
  • Loading branch information
darssen authored and matticbot committed Oct 8, 2024
1 parent b80c7ff commit 809e375
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 87 deletions.
58 changes: 29 additions & 29 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/automattic/jetpack-sync/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This is an alpha version! The changes listed here are not final.
### Added
- Jetpack Sync: Add 'woocommerce_analytics_first_activation' in options' whitelist

### Changed
- Sync: Ensure we don't sync set_object_terms action for terms with blacklisted taxonomies

## [3.13.2] - 2024-09-30
### Fixed
- Jetpack Sync: Fix a bug in syncing HPOS 'woocommerce_delete_order' actions [#39562]
Expand Down
8 changes: 6 additions & 2 deletions vendor/automattic/jetpack-sync/src/modules/class-terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,16 @@ public function filter_blacklisted_taxonomies( $args ) {
}

/**
* Filter out set_object_terms actions where the terms have not changed.
* Filter out set_object_terms actions with blacklisted taxonomies or where the terms have not changed.
*
* @param array $args Hook args.
* @return array|boolean False if no change in terms, the original hook args otherwise.
* @return array|boolean False if blacklisted taxonomy or no change in terms, the original hook args otherwise.
*/
public function filter_set_object_terms_no_update( $args ) {
// Check if the taxonomy is blacklisted. $args[3] is the taxonomy.
if ( isset( $args[3] ) && in_array( $args[3], Settings::get_setting( 'taxonomies_blacklist' ), true ) ) {
return false;
}
// There is potential for other plugins to modify args, therefore lets validate # of and types.
// $args[2] is $tt_ids, $args[5] is $old_tt_ids see wp-includes/taxonomy.php L2740.
if ( 6 === count( $args ) && is_array( $args[2] ) && is_array( $args[5] ) ) {
Expand Down
Loading

0 comments on commit 809e375

Please sign in to comment.