Skip to content

Commit 64086b2

Browse files
Editor: Correct wp_enable_real_time_collaboration default for REST API sync route.
Follow-up to [61689], [61702], [61722], [61828], [61862], [61864]. Props mindctrl, skithund, amykamala, MadtownLems, aion11, peterwilsoncc, pbiron, apermo, SergeyBiryukov. Fixes #64814. git-svn-id: https://develop.svn.wordpress.org/trunk@61865 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a8fec6f commit 64086b2

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/wp-includes/option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ function register_initial_settings() {
28922892
'type' => 'boolean',
28932893
'description' => __( 'Enable Real-Time Collaboration' ),
28942894
'sanitize_callback' => 'rest_sanitize_boolean',
2895-
'default' => false,
2895+
'default' => true,
28962896
'show_in_rest' => true,
28972897
)
28982898
);

tests/phpunit/tests/rest-api/rest-sync-server.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@ public function test_register_routes() {
9696
$this->assertArrayHasKey( '/wp-sync/v1/updates', $routes );
9797
}
9898

99+
/**
100+
* Verifies the sync route is registered when relying on the option's default
101+
* value (option not stored in the database).
102+
*
103+
* This covers the upgrade scenario where a site has never explicitly saved
104+
* the collaboration setting.
105+
*
106+
* @ticket 64814
107+
*/
108+
public function test_register_routes_with_default_option() {
109+
global $wp_rest_server;
110+
111+
// Remove the pre_option filter added in ::set_up() so get_option() uses its default logic.
112+
remove_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' );
113+
114+
// Ensure the option is not in the database.
115+
delete_option( 'wp_enable_real_time_collaboration' );
116+
117+
// Reset the REST server so routes are re-registered from scratch.
118+
$wp_rest_server = null;
119+
120+
$routes = rest_get_server()->get_routes();
121+
$this->assertArrayHasKey( '/wp-sync/v1/updates', $routes );
122+
}
123+
99124
/**
100125
* @doesNotPerformAssertions
101126
*/

0 commit comments

Comments
 (0)