Skip to content

Commit 77f01a2

Browse files
josephfuscodesrosj
authored andcommitted
Collaboration: Add type_client_id index and bump db_version
Add a composite index on (type, client_id) to the collaboration table to speed up awareness upserts, which filter on both columns. Bump $wp_db_version from 61840 to 61841 so existing installations pick up the schema change via dbDelta on upgrade.
1 parent 0350d69 commit 77f01a2

4 files changed

Lines changed: 10 additions & 43 deletions

File tree

src/wp-admin/includes/schema.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
193193
type varchar(32) NOT NULL default '',
194194
client_id varchar(32) NOT NULL default '',
195195
user_id bigint(20) unsigned NOT NULL default '0',
196-
update_value longtext NOT NULL,
196+
data longtext NOT NULL,
197197
date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
198198
PRIMARY KEY (id),
199+
KEY type_client_id (type,client_id),
199200
KEY room (room,id),
200201
KEY date_gmt (date_gmt)
201202
) $charset_collate;\n";

src/wp-admin/includes/upgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ function upgrade_all() {
886886
upgrade_682();
887887
}
888888

889-
if ( $wp_current_db_version < 61840 ) {
889+
if ( $wp_current_db_version < 61841 ) {
890890
upgrade_700();
891891
}
892892

src/wp-includes/collaboration.php

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,18 @@
77
*/
88

99
/**
10-
* Determines whether real-time collaboration is enabled.
10+
* Checks whether real-time collaboration is enabled.
1111
*
12-
* If the WP_ALLOW_COLLABORATION constant is false,
13-
* collaboration is always disabled regardless of the database option.
14-
* Otherwise, falls back to the 'wp_collaboration_enabled' option.
12+
* The feature requires both the site option and the database schema
13+
* introduced in db_version 61841.
1514
*
1615
* @since 7.0.0
1716
*
18-
* @return bool Whether real-time collaboration is enabled.
17+
* @return bool True if collaboration is enabled, false otherwise.
1918
*/
2019
function wp_is_collaboration_enabled() {
21-
return (
22-
wp_is_collaboration_allowed() &&
23-
(bool) get_option( 'wp_collaboration_enabled' )
24-
);
25-
}
26-
27-
/**
28-
* Determines whether real-time collaboration is allowed.
29-
*
30-
* If the WP_ALLOW_COLLABORATION constant is false,
31-
* collaboration is not allowed and cannot be enabled.
32-
* The constant defaults to true, unless the WP_ALLOW_COLLABORATION
33-
* environment variable is set to string "false".
34-
*
35-
* @since 7.0.0
36-
*
37-
* @return bool Whether real-time collaboration is enabled.
38-
*/
39-
function wp_is_collaboration_allowed() {
40-
if ( ! defined( 'WP_ALLOW_COLLABORATION' ) ) {
41-
$env_value = getenv( 'WP_ALLOW_COLLABORATION' );
42-
if ( false === $env_value ) {
43-
// Environment variable is not defined, default to allowing collaboration.
44-
define( 'WP_ALLOW_COLLABORATION', true );
45-
} else {
46-
/*
47-
* Environment variable is defined, let's confirm it is actually set to
48-
* "true" as it may still have a string value "false" – the preceeding
49-
* `if` branch only tests for the boolean `false`.
50-
*/
51-
define( 'WP_ALLOW_COLLABORATION', 'true' === $env_value );
52-
}
53-
}
54-
55-
return WP_ALLOW_COLLABORATION;
20+
return get_option( 'wp_enable_real_time_collaboration' )
21+
&& get_option( 'db_version' ) >= 61841;
5622
}
5723

5824
/**

src/wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @global int $wp_db_version
2525
*/
26-
$wp_db_version = 61840;
26+
$wp_db_version = 61841;
2727

2828
/**
2929
* Holds the TinyMCE version.

0 commit comments

Comments
 (0)