Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/option.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
);
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/tests/rest-api/rest-sync-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt it customary to have the global at the beginning of a function?

$wp_rest_server = null;

$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey( '/wp-sync/v1/updates', $routes );
}

/**
* @doesNotPerformAssertions
*/
Expand Down
Loading