From 9fb6019443c92e6458af0c4637ddef4dd45d9016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Mon, 23 Mar 2026 12:07:33 +0100 Subject: [PATCH 1/3] Collaboration: Define WP_ALLOW_COLLABORATION inline instead of in wp_functionality_constants() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constant was defined in wp_functionality_constants(), which runs in wp-settings.php after collaboration.php is loaded. That created a boot-order edge case where wp_is_collaboration_enabled() could be called before the constant existed – for instance via SHORTINIT. Move the constant definition into a new wp_is_collaboration_allowed() function in collaboration.php. The function checks the constant, and if it's missing, defines it on the spot from the environment variable (defaulting to true). wp_is_collaboration_enabled() now delegates to wp_is_collaboration_allowed() for the constant check, and the admin UI calls wp_is_collaboration_allowed() directly to decide whether to show the checkbox or a "disabled" notice. --- src/wp-admin/options-writing.php | 10 ++++---- src/wp-includes/collaboration.php | 36 ++++++++++++++++++++++++--- src/wp-includes/default-constants.php | 20 --------------- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/wp-admin/options-writing.php b/src/wp-admin/options-writing.php index c333d1910879f..60b7a9c3fc7a3 100644 --- a/src/wp-admin/options-writing.php +++ b/src/wp-admin/options-writing.php @@ -112,15 +112,15 @@ - -
-

Note: Real-time collaboration has been disabled.' ); ?>

-
- + + +
+

Note: Real-time collaboration has been disabled.' ); ?>

+
diff --git a/src/wp-includes/collaboration.php b/src/wp-includes/collaboration.php index 218f1feda4df7..e65149f04a63b 100644 --- a/src/wp-includes/collaboration.php +++ b/src/wp-includes/collaboration.php @@ -18,11 +18,41 @@ * @return bool Whether real-time collaboration is enabled. */ function wp_is_collaboration_enabled() { - if ( ! defined( 'WP_ALLOW_COLLABORATION' ) || ! WP_ALLOW_COLLABORATION ) { - return false; + return ( + wp_is_collaboration_allowed() && + (bool) get_option( 'wp_collaboration_enabled' ) + ); +} + +/** + * Determines whether real-time collaboration is allowed. + * + * If the WP_ALLOW_COLLABORATION constant is false, + * collaboration is not allowed and cannot be enabled. + * The constant defaults to true, unless the WP_ALLOW_COLLABORATION + * environment variable is set to string "false". + * + * @since 7.0.0 + * + * @return bool Whether real-time collaboration is enabled. + */ +function wp_is_collaboration_allowed() { + if ( ! defined( 'WP_ALLOW_COLLABORATION' ) ) { + $env_value = getenv( 'WP_ALLOW_COLLABORATION' ); + if ( false === $env_value ) { + // Environment variable is not defined, default to allowing collaboration. + define( 'WP_ALLOW_COLLABORATION', true ); + } else { + /* + * Environment variable is defined, let's confirm it is actually set to + * "true" as it may still have a string value "false" – the preceeding + * `if` branch only tests for the boolean `false`. + */ + define( 'WP_ALLOW_COLLABORATION', 'true' === $env_value ); + } } - return (bool) get_option( 'wp_collaboration_enabled' ); + return WP_ALLOW_COLLABORATION; } /** diff --git a/src/wp-includes/default-constants.php b/src/wp-includes/default-constants.php index ab0b3d6cceb9f..acfc878fb7138 100644 --- a/src/wp-includes/default-constants.php +++ b/src/wp-includes/default-constants.php @@ -398,26 +398,6 @@ function wp_functionality_constants() { if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) { define( 'WP_CRON_LOCK_TIMEOUT', MINUTE_IN_SECONDS ); } - - /** - * Whether real time collaboration is permitted to be enabled. - * - * @since 7.0.0 - */ - if ( ! defined( 'WP_ALLOW_COLLABORATION' ) ) { - $env_value = getenv( 'WP_ALLOW_COLLABORATION' ); - if ( false === $env_value ) { - // Environment variable is not defined, default to allowing collaboration. - define( 'WP_ALLOW_COLLABORATION', true ); - } else { - /* - * Environment variable is defined, let's confirm it is actually set to - * "true" as it may still have a string value "false" – the preceeding - * `if` branch only tests for the boolean `false`. - */ - define( 'WP_ALLOW_COLLABORATION', 'true' === $env_value ); - } - } } /** From d3f17b29ac42c5c357001a36a72c0e2642d7219d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Mon, 23 Mar 2026 12:12:18 +0100 Subject: [PATCH 2/3] Code Quality: Remove trailing whitespace in collaboration.php --- src/wp-includes/collaboration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/collaboration.php b/src/wp-includes/collaboration.php index e65149f04a63b..11698a2ac78f4 100644 --- a/src/wp-includes/collaboration.php +++ b/src/wp-includes/collaboration.php @@ -19,7 +19,7 @@ */ function wp_is_collaboration_enabled() { return ( - wp_is_collaboration_allowed() && + wp_is_collaboration_allowed() && (bool) get_option( 'wp_collaboration_enabled' ) ); } From 55f3d37e5d4f9c4ba3ab4272b43b7e96c2fb728d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 24 Mar 2026 12:41:40 +0100 Subject: [PATCH 3/3] Revise collaboration feature description Updated the label for collaboration feature to clarify its impact on performance. --- src/wp-admin/options-writing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/options-writing.php b/src/wp-admin/options-writing.php index 60b7a9c3fc7a3..d40dc0578b315 100644 --- a/src/wp-admin/options-writing.php +++ b/src/wp-admin/options-writing.php @@ -115,7 +115,7 @@