diff --git a/projects/packages/sync/changelog/fix-sync-callables-set-late-default b/projects/packages/sync/changelog/fix-sync-callables-set-late-default new file mode 100644 index 0000000000000..7bb57acb9f1d1 --- /dev/null +++ b/projects/packages/sync/changelog/fix-sync-callables-set-late-default @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Jetpack Sync: Ensure 'jetpack_sync_callable_whitelist' filter is respected when added late diff --git a/projects/packages/sync/src/class-package-version.php b/projects/packages/sync/src/class-package-version.php index a266f5a8bd60f..3b39ef9f3d9d3 100644 --- a/projects/packages/sync/src/class-package-version.php +++ b/projects/packages/sync/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '2.16.1'; + const PACKAGE_VERSION = '2.16.2-alpha'; const PACKAGE_SLUG = 'sync'; diff --git a/projects/packages/sync/src/modules/class-callables.php b/projects/packages/sync/src/modules/class-callables.php index eddeec2ff690f..6aceead8a0dc3 100644 --- a/projects/packages/sync/src/modules/class-callables.php +++ b/projects/packages/sync/src/modules/class-callables.php @@ -109,6 +109,28 @@ public function set_defaults() { $this->force_send_callables_on_next_tick = false; // Resets here as well mostly for tests. } + /** + * Set module defaults at a later time. + * Reset the callable whitelist if needed to account for plugins adding the 'jetpack_sync_callable_whitelist' + * and 'jetpack_sync_multisite_callable_whitelist' filters late. + * + * @see Automattic\Jetpack\Sync\Modules::set_module_defaults + * @access public + */ + public function set_late_default() { + if ( is_multisite() ) { + $late_callables = array_merge( + apply_filters( 'jetpack_sync_callable_whitelist', array() ), + apply_filters( 'jetpack_sync_multisite_callable_whitelist', array() ) + ); + } else { + $late_callables = apply_filters( 'jetpack_sync_callable_whitelist', array() ); + } + if ( ! empty( $late_callables ) && is_array( $late_callables ) ) { + $this->callable_whitelist = array_merge( $this->callable_whitelist, $late_callables ); + } + } + /** * Initialize callables action listeners. * diff --git a/projects/plugins/jetpack/changelog/fix-sync-callables-set-late-default b/projects/plugins/jetpack/changelog/fix-sync-callables-set-late-default new file mode 100644 index 0000000000000..916cb15ef262a --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-sync-callables-set-late-default @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated Sync related unit tests + + diff --git a/projects/plugins/jetpack/composer.json b/projects/plugins/jetpack/composer.json index bfb1aeb0570d3..40bb680259115 100644 --- a/projects/plugins/jetpack/composer.json +++ b/projects/plugins/jetpack/composer.json @@ -103,7 +103,7 @@ "platform": { "ext-intl": "0.0.0" }, - "autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackā“„13_5_a_1", + "autoloader-suffix": "f11009ded9fc4592b6a05b61ce272b3c_jetpackā“„13_5_a_2", "allow-plugins": { "automattic/jetpack-autoloader": true, "automattic/jetpack-composer-plugin": true diff --git a/projects/plugins/jetpack/jetpack.php b/projects/plugins/jetpack/jetpack.php index df17fae9ea070..4b7669d0b466e 100644 --- a/projects/plugins/jetpack/jetpack.php +++ b/projects/plugins/jetpack/jetpack.php @@ -4,7 +4,7 @@ * Plugin URI: https://jetpack.com * Description: Security, performance, and marketing tools made by WordPress experts. Jetpack keeps your site protected so you can focus on more important things. * Author: Automattic - * Version: 13.5-a.1 + * Version: 13.5-a.2 * Author URI: https://jetpack.com * License: GPL2+ * Text Domain: jetpack @@ -34,7 +34,7 @@ define( 'JETPACK__MINIMUM_WP_VERSION', '6.4' ); define( 'JETPACK__MINIMUM_PHP_VERSION', '7.0' ); -define( 'JETPACK__VERSION', '13.5-a.1' ); +define( 'JETPACK__VERSION', '13.5-a.2' ); /** * Constant used to fetch the connection owner token diff --git a/projects/plugins/jetpack/package.json b/projects/plugins/jetpack/package.json index 354278661a428..4f0b82ff2b765 100644 --- a/projects/plugins/jetpack/package.json +++ b/projects/plugins/jetpack/package.json @@ -1,6 +1,6 @@ { "name": "Jetpack", - "version": "13.5.0-a.1", + "version": "13.5.0-a.2", "private": true, "description": "[Jetpack](https://jetpack.com/) is a WordPress plugin that supercharges your self-hosted WordPress site with the awesome cloud power of [WordPress.com](https://wordpress.com).", "homepage": "https://jetpack.com", diff --git a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-callables.php b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-callables.php index e6496916a0e79..616435a87e5fb 100644 --- a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-callables.php +++ b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-callables.php @@ -230,6 +230,26 @@ public function test_white_listed_callable_sync_on_next_tick() { $this->assertNotEquals( $initial_value, $new_value ); } + /** + * Tests that calling set_late_default works as expected. + * + * Return null + */ + public function test_sync_callable_set_late_default() { + $this->callable_module->set_callable_whitelist( array() ); + + add_filter( 'jetpack_sync_callable_whitelist', array( $this, 'filter_sync_callable_whitelist' ) ); + + $this->callable_module->set_late_default(); + + remove_filter( 'jetpack_sync_callable_whitelist', array( $this, 'filter_sync_callable_whitelist' ) ); + + $this->sender->do_sync(); + + $synced_value = $this->server_replica_storage->get_callable( 'jetpack_foo' ); + $this->assertEquals( jetpack_foo_is_callable(), $synced_value ); + } + /** * Tests that updating the theme should result in the no callabled transient being set. * @@ -976,6 +996,18 @@ public function add_www_subdomain_to_siteurl( $url ) { return "{$parsed_url['scheme']}://www.{$parsed_url['host']}"; } + /** + * Filters the sync callable whitelist. + * + * @param array $whitelist The sync callable whitelist. + * @return array + */ + public function filter_sync_callable_whitelist( $whitelist ) { + $whitelist['jetpack_foo'] = 'jetpack_foo_is_callable'; + + return $whitelist; + } + /** * Test "taxonomies_objects_do_not_have_meta_box_callback". */