Skip to content

Commit a9fbc1b

Browse files
committed
Revert "Real-time collaboration: enable by default."
This reverts commit 194f764.
1 parent e1c433c commit a9fbc1b

12 files changed

Lines changed: 34 additions & 138 deletions

File tree

src/wp-admin/includes/schema.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ function populate_options( array $options = array() ) {
563563

564564
// 6.9.0
565565
'wp_notes_notify' => 1,
566+
567+
// 7.0.0
568+
'wp_enable_real_time_collaboration' => 0,
566569
);
567570

568571
// 3.3.0

src/wp-admin/options-writing.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@
110110
</td>
111111
</tr>
112112
<tr>
113-
<th scope="row"><label for="wp_disable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
113+
<th scope="row"><label for="wp_enable_real_time_collaboration"><?php _e( 'Collaboration' ); ?></label></th>
114114
<td>
115-
<input name="wp_disable_real_time_collaboration" type="checkbox" id="wp_disable_real_time_collaboration" value="1" <?php checked( '1', get_option( 'wp_disable_real_time_collaboration' ) ); ?> />
116-
<label for="wp_disable_real_time_collaboration"><?php _e( 'Disable real-time collaboration' ); ?></label>
115+
<input name="wp_enable_real_time_collaboration" type="checkbox" id="wp_enable_real_time_collaboration" value="1" <?php checked( '1', get_option( 'wp_enable_real_time_collaboration' ) ); ?> />
116+
<label for="wp_enable_real_time_collaboration"><?php _e( 'Enable real-time collaboration' ); ?></label>
117117
</td>
118118
</tr>
119119
<?php

src/wp-admin/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
'default_email_category',
154154
'default_link_category',
155155
'default_post_format',
156-
'wp_disable_real_time_collaboration',
156+
'wp_enable_real_time_collaboration',
157157
),
158158
);
159159
$allowed_options['misc'] = array();

src/wp-includes/collaboration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @access private
1515
*/
1616
function wp_collaboration_inject_setting() {
17-
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
17+
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
1818
wp_add_inline_script(
1919
'wp-core-data',
2020
'window._wpCollaborationEnabled = true;',

src/wp-includes/option.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,10 +2887,10 @@ function register_initial_settings() {
28872887

28882888
register_setting(
28892889
'writing',
2890-
'wp_disable_real_time_collaboration',
2890+
'wp_enable_real_time_collaboration',
28912891
array(
28922892
'type' => 'boolean',
2893-
'description' => __( 'Disable real-time collaboration' ),
2893+
'description' => __( 'Enable Real-Time Collaboration' ),
28942894
'sanitize_callback' => 'rest_sanitize_boolean',
28952895
'default' => false,
28962896
'show_in_rest' => true,

src/wp-includes/post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ function create_initial_post_types() {
657657
)
658658
);
659659

660-
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
660+
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
661661
register_post_type(
662662
'wp_sync_storage',
663663
array(
@@ -8671,7 +8671,7 @@ function wp_create_initial_post_meta() {
86718671
)
86728672
);
86738673

8674-
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
8674+
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
86758675
register_meta(
86768676
'post',
86778677
'_crdt_document',

src/wp-includes/rest-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ function create_initial_rest_routes() {
430430
$icons_controller->register_routes();
431431

432432
// Collaboration.
433-
if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) {
433+
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
434434
$sync_storage = new WP_Sync_Post_Meta_Storage();
435435
$sync_server = new WP_HTTP_Polling_Sync_Server( $sync_storage );
436436
$sync_server->register_routes();

src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ public function create_item( $request ) {
254254
* the saved post. This diff is then applied to the in-memory CRDT
255255
* document, which can lead to duplicate inserts or deletions.
256256
*/
257-
$is_collaboration_disabled = boolval( get_option( 'wp_disable_real_time_collaboration' ) );
257+
$is_collaboration_enabled = get_option( 'wp_enable_real_time_collaboration' );
258258

259-
if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && $is_collaboration_disabled ) {
259+
if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && ! $is_collaboration_enabled ) {
260260
/*
261261
* Draft posts for the same author: autosaving updates the post and does not create a revision.
262262
* Convert the post object to an array and add slashes, wp_update_post() expects escaped array.

tests/phpunit/tests/rest-api/rest-autosaves-controller.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,8 @@ public function test_rest_autosave_published_post() {
570570
}
571571

572572
public function test_rest_autosave_draft_post_same_author() {
573-
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
573+
$original_option = get_option( 'wp_enable_real_time_collaboration' );
574+
update_option( 'wp_enable_real_time_collaboration', false );
574575

575576
wp_set_current_user( self::$editor_id );
576577

@@ -606,7 +607,7 @@ public function test_rest_autosave_draft_post_same_author() {
606607
$this->assertSame( $post_data['post_excerpt'], $post->post_excerpt );
607608

608609
wp_delete_post( $post_id );
609-
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
610+
update_option( 'wp_enable_real_time_collaboration', $original_option );
610611
}
611612

612613
public function test_rest_autosave_draft_post_different_author() {
@@ -747,7 +748,8 @@ public function test_get_item_sets_up_postdata() {
747748
}
748749

749750
public function test_update_item_draft_page_with_parent() {
750-
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
751+
$original_option = get_option( 'wp_enable_real_time_collaboration' );
752+
update_option( 'wp_enable_real_time_collaboration', false );
751753

752754
wp_set_current_user( self::$editor_id );
753755
$request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' );
@@ -766,8 +768,7 @@ public function test_update_item_draft_page_with_parent() {
766768

767769
$this->assertSame( self::$child_draft_page_id, $data['id'] );
768770
$this->assertSame( self::$parent_page_id, $data['parent'] );
769-
770-
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' );
771+
update_option( 'wp_enable_real_time_collaboration', $original_option );
771772
}
772773

773774
public function test_schema_validation_is_applied() {
@@ -933,7 +934,8 @@ public static function data_head_request_with_specified_fields_returns_success_r
933934
* same author should create a revision instead of updating the post directly.
934935
*/
935936
public function test_rest_autosave_draft_post_same_author_with_rtc() {
936-
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
937+
$original_option = get_option( 'wp_enable_real_time_collaboration' );
938+
update_option( 'wp_enable_real_time_collaboration', true );
937939

938940
wp_set_current_user( self::$editor_id );
939941

@@ -972,15 +974,16 @@ public function test_rest_autosave_draft_post_same_author_with_rtc() {
972974
$this->assertSame( $post_data['post_excerpt'], $post->post_excerpt );
973975

974976
wp_delete_post( $post_id );
975-
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
977+
update_option( 'wp_enable_real_time_collaboration', $original_option );
976978
}
977979

978980
/**
979981
* When real-time collaboration is enabled, autosaving a draft page with
980982
* a parent should create a revision instead of updating the page directly.
981983
*/
982984
public function test_update_item_draft_page_with_parent_with_rtc() {
983-
add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
985+
$original_option = get_option( 'wp_enable_real_time_collaboration' );
986+
update_option( 'wp_enable_real_time_collaboration', true );
984987

985988
wp_set_current_user( self::$editor_id );
986989
$request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' );
@@ -1000,7 +1003,6 @@ public function test_update_item_draft_page_with_parent_with_rtc() {
10001003
// With RTC enabled, a revision is created instead of updating the page.
10011004
$this->assertNotSame( self::$child_draft_page_id, $data['id'] );
10021005
$this->assertSame( self::$child_draft_page_id, $data['parent'] );
1003-
1004-
remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' );
1006+
update_option( 'wp_enable_real_time_collaboration', $original_option );
10051007
}
10061008
}

tests/phpunit/tests/rest-api/rest-settings-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function test_get_items() {
119119
'default_ping_status',
120120
'default_comment_status',
121121
'site_icon', // Registered in wp-includes/blocks/site-logo.php
122-
'wp_disable_real_time_collaboration',
122+
'wp_enable_real_time_collaboration',
123123
// Connectors API keys are registered in _wp_register_default_connector_settings() in wp-includes/connectors.php.
124124
'connectors_ai_anthropic_api_key',
125125
'connectors_ai_google_api_key',

0 commit comments

Comments
 (0)