diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index 40b907d282a20..a3352aa57f86e 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -2892,7 +2892,7 @@ function register_initial_settings() { 'type' => 'boolean', 'description' => __( 'Enable Real-Time Collaboration' ), 'sanitize_callback' => 'rest_sanitize_boolean', - 'default' => false, + 'default' => true, 'show_in_rest' => true, ) ); diff --git a/tests/phpunit/tests/rest-api/rest-sync-server.php b/tests/phpunit/tests/rest-api/rest-sync-server.php index a18171b27b850..d3b80e2e16b7b 100644 --- a/tests/phpunit/tests/rest-api/rest-sync-server.php +++ b/tests/phpunit/tests/rest-api/rest-sync-server.php @@ -96,6 +96,30 @@ public function test_register_routes() { $this->assertArrayHasKey( '/wp-sync/v1/updates', $routes ); } + /** + * Verifies the sync route is registered when relying on the option's default + * value (option not stored in the database). + * + * This covers the upgrade scenario where a site has never explicitly saved + * the collaboration setting. + * + * @ticket 64814 + */ + public function test_register_routes_with_default_option() { + // Remove the pre_option filter added in set_up() so get_option() uses its default logic. + remove_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); + + // Ensure the option is not in the database. + delete_option( 'wp_enable_real_time_collaboration' ); + + // Reset the REST server so routes are re-registered from scratch. + global $wp_rest_server; + $wp_rest_server = null; + + $routes = rest_get_server()->get_routes(); + $this->assertArrayHasKey( '/wp-sync/v1/updates', $routes ); + } + /** * @doesNotPerformAssertions */