From a9fbc1bf7d98d517b3f537b8e565fa31277430a4 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 08:29:35 +1100 Subject: [PATCH 1/7] Revert "Real-time collaboration: enable by default." This reverts commit 194f76458fa3c75e2e13c624a9950cd2333638ac. --- src/wp-admin/includes/schema.php | 3 + src/wp-admin/options-writing.php | 6 +- src/wp-admin/options.php | 2 +- src/wp-includes/collaboration.php | 2 +- src/wp-includes/option.php | 4 +- src/wp-includes/post.php | 4 +- src/wp-includes/rest-api.php | 2 +- .../class-wp-rest-autosaves-controller.php | 4 +- .../rest-api/rest-autosaves-controller.php | 22 ++-- .../rest-api/rest-settings-controller.php | 2 +- .../tests/rest-api/rest-sync-server.php | 4 +- tests/qunit/fixtures/wp-api-generated.js | 117 +----------------- 12 files changed, 34 insertions(+), 138 deletions(-) diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 3aa377a0edd43..7a95f65ad80cc 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' => 0, ); // 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..b2236e5b0de02 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -570,7 +570,8 @@ 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' ); + $original_option = get_option( 'wp_enable_real_time_collaboration' ); + update_option( 'wp_enable_real_time_collaboration', false ); wp_set_current_user( self::$editor_id ); @@ -606,7 +607,7 @@ 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' ); + update_option( 'wp_enable_real_time_collaboration', $original_option ); } public function test_rest_autosave_draft_post_different_author() { @@ -747,7 +748,8 @@ 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' ); + $original_option = get_option( 'wp_enable_real_time_collaboration' ); + update_option( 'wp_enable_real_time_collaboration', false ); wp_set_current_user( self::$editor_id ); $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() { $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' ); + update_option( 'wp_enable_real_time_collaboration', $original_option ); } public function test_schema_validation_is_applied() { @@ -933,7 +934,8 @@ 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' ); + $original_option = get_option( 'wp_enable_real_time_collaboration' ); + update_option( 'wp_enable_real_time_collaboration', true ); wp_set_current_user( self::$editor_id ); @@ -972,7 +974,7 @@ 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' ); + update_option( 'wp_enable_real_time_collaboration', $original_option ); } /** @@ -980,7 +982,8 @@ 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' ); + $original_option = get_option( 'wp_enable_real_time_collaboration' ); + update_option( 'wp_enable_real_time_collaboration', 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 +1003,6 @@ 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' ); + update_option( 'wp_enable_real_time_collaboration', $original_option ); } } 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..a09b256115f48 100644 --- a/tests/phpunit/tests/rest-api/rest-sync-server.php +++ b/tests/phpunit/tests/rest-api/rest-sync-server.php @@ -14,7 +14,7 @@ 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' ); + update_option( 'wp_enable_real_time_collaboration', true ); self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) ); self::$subscriber_id = $factory->user->create( array( 'role' => 'subscriber' ) ); @@ -25,7 +25,7 @@ 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' ); + delete_option( 'wp_enable_real_time_collaboration' ); } public function set_up() { diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index f5a7d8dfe959c..487fb2067a978 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -20,8 +20,7 @@ mockedApiResponse.Schema = { "wp/v2", "wp-site-health/v1", "wp-block-editor/v1", - "wp-abilities/v1", - "wp-sync/v1" + "wp-abilities/v1" ], "authentication": { "application-passwords": { @@ -11158,9 +11157,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 }, @@ -12771,114 +12770,6 @@ mockedApiResponse.Schema = { } } ] - }, - "/wp-sync/v1": { - "namespace": "wp-sync/v1", - "methods": [ - "GET" - ], - "endpoints": [ - { - "methods": [ - "GET" - ], - "args": { - "namespace": { - "default": "wp-sync/v1", - "required": false - }, - "context": { - "default": "view", - "required": false - } - } - } - ], - "_links": { - "self": [ - { - "href": "http://example.org/index.php?rest_route=/wp-sync/v1" - } - ] - } - }, - "/wp-sync/v1/updates": { - "namespace": "wp-sync/v1", - "methods": [ - "POST" - ], - "endpoints": [ - { - "methods": [ - "POST" - ], - "args": { - "rooms": { - "items": { - "properties": { - "after": { - "minimum": 0, - "required": true, - "type": "integer" - }, - "awareness": { - "required": true, - "type": [ - "object", - "null" - ] - }, - "client_id": { - "minimum": 1, - "required": true, - "type": "integer" - }, - "room": { - "required": true, - "type": "string", - "pattern": "^[^/]+/[^/:]+(?::\\S+)?$" - }, - "updates": { - "items": { - "properties": { - "data": { - "type": "string", - "required": true - }, - "type": { - "type": "string", - "required": true, - "enum": [ - "compaction", - "sync_step1", - "sync_step2", - "update" - ] - } - }, - "required": true, - "type": "object" - }, - "minItems": 0, - "required": true, - "type": "array" - } - }, - "type": "object" - }, - "type": "array", - "required": true - } - } - } - ], - "_links": { - "self": [ - { - "href": "http://example.org/index.php?rest_route=/wp-sync/v1/updates" - } - ] - } } }, "image_sizes": { @@ -14777,7 +14668,7 @@ mockedApiResponse.settings = { "use_smilies": true, "default_category": 1, "default_post_format": "0", - "wp_disable_real_time_collaboration": false, + "wp_enable_real_time_collaboration": false, "posts_per_page": 10, "show_on_front": "posts", "page_on_front": 0, From 03be04b345e9d6bdd801bb12c25e837c0b0874c8 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 08:30:34 +1100 Subject: [PATCH 2/7] Enable RTC by default. --- src/wp-admin/includes/schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 7a95f65ad80cc..0c3f36338cf2b 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -565,7 +565,7 @@ function populate_options( array $options = array() ) { 'wp_notes_notify' => 1, // 7.0.0 - 'wp_enable_real_time_collaboration' => 0, + 'wp_enable_real_time_collaboration' => 1, ); // 3.3.0 From 45c8352f88a6bdf43e50540adb3b5db79599c06a Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 08:53:35 +1100 Subject: [PATCH 3/7] Enable RTC without requiring upgrade routine to run. --- src/wp-includes/default-filters.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 8ce256e046f84..0bcd2d6b15acb 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -485,8 +485,9 @@ // Timezone. add_filter( 'pre_option_gmt_offset', 'wp_timezone_override_offset' ); -// If the upgrade hasn't run yet, assume link manager is used. -add_filter( 'default_option_link_manager_enabled', '__return_true' ); +// If the upgrade hasn't run yet, set some default options. +add_filter( 'default_option_link_manager_enabled', '__return_true' ); // Assume link manager is used. +add_filter( 'default_option_wp_enable_real_time_collaboration', '__return_true' ); // Enable real-time collaboration. // This option no longer exists; tell plugins we always support auto-embedding. add_filter( 'pre_option_embed_autourls', '__return_true' ); From 80c9c4a6d324ddddc8d7263ea74120ba91e9f9b9 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 09:13:31 +1100 Subject: [PATCH 4/7] Regenerate `wp-api-generated.js`. --- tests/qunit/fixtures/wp-api-generated.js | 113 ++++++++++++++++++++++- 1 file changed, 111 insertions(+), 2 deletions(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 487fb2067a978..a8e8c6280600c 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -20,7 +20,8 @@ mockedApiResponse.Schema = { "wp/v2", "wp-site-health/v1", "wp-block-editor/v1", - "wp-abilities/v1" + "wp-abilities/v1", + "wp-sync/v1" ], "authentication": { "application-passwords": { @@ -12770,6 +12771,114 @@ mockedApiResponse.Schema = { } } ] + }, + "/wp-sync/v1": { + "namespace": "wp-sync/v1", + "methods": [ + "GET" + ], + "endpoints": [ + { + "methods": [ + "GET" + ], + "args": { + "namespace": { + "default": "wp-sync/v1", + "required": false + }, + "context": { + "default": "view", + "required": false + } + } + } + ], + "_links": { + "self": [ + { + "href": "http://example.org/index.php?rest_route=/wp-sync/v1" + } + ] + } + }, + "/wp-sync/v1/updates": { + "namespace": "wp-sync/v1", + "methods": [ + "POST" + ], + "endpoints": [ + { + "methods": [ + "POST" + ], + "args": { + "rooms": { + "items": { + "properties": { + "after": { + "minimum": 0, + "required": true, + "type": "integer" + }, + "awareness": { + "required": true, + "type": [ + "object", + "null" + ] + }, + "client_id": { + "minimum": 1, + "required": true, + "type": "integer" + }, + "room": { + "required": true, + "type": "string", + "pattern": "^[^/]+/[^/:]+(?::\\S+)?$" + }, + "updates": { + "items": { + "properties": { + "data": { + "type": "string", + "required": true + }, + "type": { + "type": "string", + "required": true, + "enum": [ + "compaction", + "sync_step1", + "sync_step2", + "update" + ] + } + }, + "required": true, + "type": "object" + }, + "minItems": 0, + "required": true, + "type": "array" + } + }, + "type": "object" + }, + "type": "array", + "required": true + } + } + } + ], + "_links": { + "self": [ + { + "href": "http://example.org/index.php?rest_route=/wp-sync/v1/updates" + } + ] + } } }, "image_sizes": { @@ -14668,7 +14777,7 @@ mockedApiResponse.settings = { "use_smilies": true, "default_category": 1, "default_post_format": "0", - "wp_enable_real_time_collaboration": false, + "wp_enable_real_time_collaboration": true, "posts_per_page": 10, "show_on_front": "posts", "page_on_front": 0, From 3a0d92ee1d08cc65704d9ac1b0114f004b8498f1 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 09:26:16 +1100 Subject: [PATCH 5/7] Apply test changes from earlier commit, varied for reverted option name change. --- .../tests/rest-api/rest-autosaves-controller.php | 16 ++++------------ .../phpunit/tests/rest-api/rest-sync-server.php | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index b2236e5b0de02..4c5e79e9eac94 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -570,8 +570,7 @@ public function test_rest_autosave_published_post() { } public function test_rest_autosave_draft_post_same_author() { - $original_option = get_option( 'wp_enable_real_time_collaboration' ); - update_option( 'wp_enable_real_time_collaboration', false ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_false' ); wp_set_current_user( self::$editor_id ); @@ -607,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 ); - update_option( 'wp_enable_real_time_collaboration', $original_option ); } public function test_rest_autosave_draft_post_different_author() { @@ -748,8 +746,7 @@ public function test_get_item_sets_up_postdata() { } public function test_update_item_draft_page_with_parent() { - $original_option = get_option( 'wp_enable_real_time_collaboration' ); - update_option( 'wp_enable_real_time_collaboration', false ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_false' ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' ); @@ -768,7 +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'] ); - update_option( 'wp_enable_real_time_collaboration', $original_option ); } public function test_schema_validation_is_applied() { @@ -934,8 +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() { - $original_option = get_option( 'wp_enable_real_time_collaboration' ); - update_option( 'wp_enable_real_time_collaboration', true ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); wp_set_current_user( self::$editor_id ); @@ -974,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 ); - update_option( 'wp_enable_real_time_collaboration', $original_option ); } /** @@ -982,8 +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() { - $original_option = get_option( 'wp_enable_real_time_collaboration' ); - update_option( 'wp_enable_real_time_collaboration', true ); + 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' ); @@ -1003,6 +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'] ); - update_option( 'wp_enable_real_time_collaboration', $original_option ); } } diff --git a/tests/phpunit/tests/rest-api/rest-sync-server.php b/tests/phpunit/tests/rest-api/rest-sync-server.php index a09b256115f48..7d81b0abb4868 100644 --- a/tests/phpunit/tests/rest-api/rest-sync-server.php +++ b/tests/phpunit/tests/rest-api/rest-sync-server.php @@ -14,7 +14,7 @@ class WP_Test_REST_Sync_Server extends WP_Test_REST_Controller_Testcase { protected static $post_id; public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { - update_option( 'wp_enable_real_time_collaboration', true ); + add_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) ); self::$subscriber_id = $factory->user->create( array( 'role' => 'subscriber' ) ); @@ -25,7 +25,7 @@ public static function wpTearDownAfterClass() { self::delete_user( self::$editor_id ); self::delete_user( self::$subscriber_id ); wp_delete_post( self::$post_id, true ); - delete_option( 'wp_enable_real_time_collaboration' ); + remove_filter( 'pre_option_wp_enable_real_time_collaboration', '__return_true' ); } public function set_up() { From 558257b6d1cb3425d4f97096eb9c0fa75ea2b786 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 09:31:35 +1100 Subject: [PATCH 6/7] Move filter to setUp to avoid need for removal in class level tear down. --- tests/phpunit/tests/rest-api/rest-sync-server.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-sync-server.php b/tests/phpunit/tests/rest-api/rest-sync-server.php index 7d81b0abb4868..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_enable_real_time_collaboration', '__return_true' ); - 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_enable_real_time_collaboration', '__return_true' ); } 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 ) { From 9345ea777dc6e70d32e46c1248d44012a042eb4d Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 5 Mar 2026 10:04:33 +1100 Subject: [PATCH 7/7] Use zero for pre-flighting the RTC option, see `get_option()`. --- tests/phpunit/tests/rest-api/rest-autosaves-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index 4c5e79e9eac94..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_enable_real_time_collaboration', '__return_false' ); + 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 ); @@ -746,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_enable_real_time_collaboration', '__return_false' ); + 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' );