Skip to content

Commit

Permalink
Update/sync add feature flag use rest api for sending (Automattic#36118)
Browse files Browse the repository at this point in the history
* Sync: Add feature flag for using rest api for sync

* add changelog

* Added into sync settings and created method to check if it is enabled or not

* Changelog

* Change names of the option to sync to wpcom_rest_api_enabled

* Updated the comments after changing names of variable

* Update projects/packages/sync/src/class-settings.php

Co-authored-by: Foteini Giannaropoulou <[email protected]>

* Fixed spacing

---------

Co-authored-by: Foteini Giannaropoulou <[email protected]>
  • Loading branch information
darssen and fgiannar authored Mar 4, 2024
1 parent 4471fce commit 1adad87
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Sync: Add feature flag for enabling the use of rest api for sending the sync data
1 change: 1 addition & 0 deletions projects/packages/sync/src/class-data-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Data_Settings {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
/**
* Connection related options
*/
Expand Down
8 changes: 8 additions & 0 deletions projects/packages/sync/src/class-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class Defaults {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled', // is Dedicated Sync flow enabled.
'jetpack_sync_settings_custom_queue_table_enabled', // is custom queue table enabled.
'jetpack_sync_settings_wpcom_rest_api_enabled', // is wpcom rest api enabled.
'jetpack_testimonial',
'jetpack_testimonial_posts_per_page',
'jetpack_wga',
Expand Down Expand Up @@ -1324,4 +1325,11 @@ public static function is_multi_network() {
* @var int Bool-ish. Default 0.
*/
public static $default_custom_queue_table_enabled = 0;

/**
* Default for enabling wpcom rest api for Sync.
*
* @var int Bool-ish. Default 0.
*/
public static $default_wpcom_rest_api_enabled = 0;
}
13 changes: 13 additions & 0 deletions projects/packages/sync/src/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Settings {
'checksum_disable' => true,
'dedicated_sync_enabled' => true,
'custom_queue_table_enabled' => true,
'wpcom_rest_api_enabled' => true,
);

/**
Expand Down Expand Up @@ -678,4 +679,16 @@ public static function is_dedicated_sync_enabled() {
public static function is_custom_queue_table_enabled() {
return (bool) self::get_setting( 'custom_queue_table_enabled' );
}

/**
* Whether wpcom rest api is enabled.
*
* @access public
* @static
*
* @return boolean Whether wpcom rest api is enabled.
*/
public static function is_wpcom_rest_api_enabled() {
return (bool) self::get_setting( 'wpcom_rest_api_enabled' );
}
}
5 changes: 5 additions & 0 deletions projects/packages/sync/tests/php/data-test-data-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public static function data_test_3() {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
'jetpack_connection_active_plugins',
'jetpack_package_versions',
'blog_charset',
Expand Down Expand Up @@ -521,6 +522,7 @@ public static function data_test_7() {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
'jetpack_connection_active_plugins',
'jetpack_package_versions',
'blog_charset',
Expand Down Expand Up @@ -574,6 +576,7 @@ public static function data_test_7_1() {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
'jetpack_connection_active_plugins',
'jetpack_package_versions',
'blog_charset',
Expand Down Expand Up @@ -630,6 +633,7 @@ public static function data_test_7_2() {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
'jetpack_connection_active_plugins',
'jetpack_package_versions',
'blog_charset',
Expand Down Expand Up @@ -866,6 +870,7 @@ public static function data_test_10() {
'jetpack_sync_settings_taxonomies_blacklist',
'jetpack_sync_settings_dedicated_sync_enabled',
'jetpack_sync_settings_custom_queue_table_enabled',
'jetpack_sync_settings_wpcom_rest_api_enabled',
'jetpack_connection_active_plugins',
'jetpack_package_versions',
'blog_charset',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Sync:Add feature flag for enabling the use of rest api for sending the sync data
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public function test_sync_default_options() {
'jetpack_sync_non_blocking' => false,
'jetpack_sync_settings_dedicated_sync_enabled' => false,
'jetpack_sync_settings_custom_queue_table_enabled' => false,
'jetpack_sync_settings_wpcom_rest_api_enabled' => false,
'jetpack_sync_settings_comment_meta_whitelist' => array( 'jetpack', 'pineapple' ),
'jetpack_sync_settings_post_meta_whitelist' => array( 'jetpack', 'pineapple' ),
'jetpack_sync_settings_post_types_blacklist' => array( 'jetpack', 'pineapple' ),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


0 comments on commit 1adad87

Please sign in to comment.