diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 3aa377a0edd43..0c3f36338cf2b 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -563,6 +563,9 @@ function populate_options( array $options = array() ) { // 6.9.0 'wp_notes_notify' => 1, + + // 7.0.0 + 'wp_enable_real_time_collaboration' => 1, ); // 3.3.0 diff --git a/src/wp-admin/options-writing.php b/src/wp-admin/options-writing.php index 0166a2927431d..e9031cec59f1e 100644 --- a/src/wp-admin/options-writing.php +++ b/src/wp-admin/options-writing.php @@ -110,10 +110,10 @@ - + - /> - + /> + 'boolean', - 'description' => __( 'Disable real-time collaboration' ), + 'description' => __( 'Enable Real-Time Collaboration' ), 'sanitize_callback' => 'rest_sanitize_boolean', 'default' => false, 'show_in_rest' => true, diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 6deb00f0fcd26..896142603278b 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -657,7 +657,7 @@ function create_initial_post_types() { ) ); - if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) { + if ( get_option( 'wp_enable_real_time_collaboration' ) ) { register_post_type( 'wp_sync_storage', array( @@ -8671,7 +8671,7 @@ function wp_create_initial_post_meta() { ) ); - if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) { + if ( get_option( 'wp_enable_real_time_collaboration' ) ) { register_meta( 'post', '_crdt_document', diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 471070b22fd8f..df7f262d3aa58 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -430,7 +430,7 @@ function create_initial_rest_routes() { $icons_controller->register_routes(); // Collaboration. - if ( ! boolval( get_option( 'wp_disable_real_time_collaboration' ) ) ) { + if ( get_option( 'wp_enable_real_time_collaboration' ) ) { $sync_storage = new WP_Sync_Post_Meta_Storage(); $sync_server = new WP_HTTP_Polling_Sync_Server( $sync_storage ); $sync_server->register_routes(); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php index 881fd80146335..36839d9c72bbf 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php @@ -254,9 +254,9 @@ public function create_item( $request ) { * the saved post. This diff is then applied to the in-memory CRDT * document, which can lead to duplicate inserts or deletions. */ - $is_collaboration_disabled = boolval( get_option( 'wp_disable_real_time_collaboration' ) ); + $is_collaboration_enabled = get_option( 'wp_enable_real_time_collaboration' ); - if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && $is_collaboration_disabled ) { + if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && ! $is_collaboration_enabled ) { /* * Draft posts for the same author: autosaving updates the post and does not create a revision. * Convert the post object to an array and add slashes, wp_update_post() expects escaped array. diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index 6180feb356b7d..892ff2c6ca2c6 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -570,7 +570,7 @@ public function test_rest_autosave_published_post() { } public function test_rest_autosave_draft_post_same_author() { - add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options. wp_set_current_user( self::$editor_id ); @@ -606,7 +606,6 @@ public function test_rest_autosave_draft_post_same_author() { $this->assertSame( $post_data['post_excerpt'], $post->post_excerpt ); wp_delete_post( $post_id ); - remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' ); } public function test_rest_autosave_draft_post_different_author() { @@ -747,7 +746,7 @@ public function test_get_item_sets_up_postdata() { } public function test_update_item_draft_page_with_parent() { - add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_zero' ); // Zero as false doesn't work for pre-flight options. wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' ); @@ -766,8 +765,6 @@ public function test_update_item_draft_page_with_parent() { $this->assertSame( self::$child_draft_page_id, $data['id'] ); $this->assertSame( self::$parent_page_id, $data['parent'] ); - - remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_true' ); } public function test_schema_validation_is_applied() { @@ -933,7 +930,7 @@ public static function data_head_request_with_specified_fields_returns_success_r * same author should create a revision instead of updating the post directly. */ public function test_rest_autosave_draft_post_same_author_with_rtc() { - add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); wp_set_current_user( self::$editor_id ); @@ -972,7 +969,6 @@ public function test_rest_autosave_draft_post_same_author_with_rtc() { $this->assertSame( $post_data['post_excerpt'], $post->post_excerpt ); wp_delete_post( $post_id ); - remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); } /** @@ -980,7 +976,7 @@ public function test_rest_autosave_draft_post_same_author_with_rtc() { * a parent should create a revision instead of updating the page directly. */ public function test_update_item_draft_page_with_parent_with_rtc() { - add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' ); @@ -1000,7 +996,5 @@ public function test_update_item_draft_page_with_parent_with_rtc() { // With RTC enabled, a revision is created instead of updating the page. $this->assertNotSame( self::$child_draft_page_id, $data['id'] ); $this->assertSame( self::$child_draft_page_id, $data['parent'] ); - - remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); } } diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index 57eee0a9e4c60..ef9e72e6a6724 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -119,7 +119,7 @@ public function test_get_items() { 'default_ping_status', 'default_comment_status', 'site_icon', // Registered in wp-includes/blocks/site-logo.php - 'wp_disable_real_time_collaboration', + 'wp_enable_real_time_collaboration', // Connectors API keys are registered in _wp_register_default_connector_settings() in wp-includes/connectors.php. 'connectors_ai_anthropic_api_key', 'connectors_ai_google_api_key', diff --git a/tests/phpunit/tests/rest-api/rest-sync-server.php b/tests/phpunit/tests/rest-api/rest-sync-server.php index a6a3aed3abf29..5ad4316eabc8c 100644 --- a/tests/phpunit/tests/rest-api/rest-sync-server.php +++ b/tests/phpunit/tests/rest-api/rest-sync-server.php @@ -14,8 +14,6 @@ class WP_Test_REST_Sync_Server extends WP_Test_REST_Controller_Testcase { protected static $post_id; public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { - add_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); - self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) ); self::$subscriber_id = $factory->user->create( array( 'role' => 'subscriber' ) ); self::$post_id = $factory->post->create( array( 'post_author' => self::$editor_id ) ); @@ -25,12 +23,14 @@ public static function wpTearDownAfterClass() { self::delete_user( self::$editor_id ); self::delete_user( self::$subscriber_id ); wp_delete_post( self::$post_id, true ); - remove_filter( 'pre_option_wp_disable_real_time_collaboration', '__return_false' ); } public function set_up() { parent::set_up(); + // Enable option for tests. + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); + // Reset storage post ID cache to ensure clean state after transaction rollback. $reflection = new ReflectionProperty( 'WP_Sync_Post_Meta_Storage', 'storage_post_ids' ); if ( PHP_VERSION_ID < 80100 ) { diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index f5a7d8dfe959c..a8e8c6280600c 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -11158,9 +11158,9 @@ mockedApiResponse.Schema = { "type": "string", "required": false }, - "wp_disable_real_time_collaboration": { + "wp_enable_real_time_collaboration": { "title": "", - "description": "Disable real-time collaboration", + "description": "Enable Real-Time Collaboration", "type": "boolean", "required": false }, @@ -14777,7 +14777,7 @@ mockedApiResponse.settings = { "use_smilies": true, "default_category": 1, "default_post_format": "0", - "wp_disable_real_time_collaboration": false, + "wp_enable_real_time_collaboration": true, "posts_per_page": 10, "show_on_front": "posts", "page_on_front": 0,