Skip to content

Collaboration: Replace post meta storage with dedicated database table#11256

Draft
josephfusco wants to merge 12 commits intoWordPress:trunkfrom
josephfusco:collaboration/single-table
Draft

Collaboration: Replace post meta storage with dedicated database table#11256
josephfusco wants to merge 12 commits intoWordPress:trunkfrom
josephfusco:collaboration/single-table

Conversation

@josephfusco
Copy link

@josephfusco josephfusco commented Mar 14, 2026

The real-time collaboration sync layer currently stores messages as post meta, which works but creates side effects at scale. This moves it to a single dedicated wp_collaboration table purpose-built for the workload.

Table Definition

CREATE TABLE wp_collaboration (
    id bigint(20) unsigned NOT NULL auto_increment,
    room varchar(191) NOT NULL default '',
    type varchar(32) NOT NULL default '',
    client_id varchar(32) NOT NULL default '',
    user_id bigint(20) unsigned NOT NULL default '0',
    update_value longtext NOT NULL,
    date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY  (id),
    KEY room (room, id),
    KEY date_gmt (date_gmt)
);

Testing

npm run env:cli -- core update-db

Testers who already had the local env running before checking out your branch will hit the upgrade.php redirect without it. A fresh npm run env:install would also work, but core update-db is non-destructive and faster.

# Unit tests
npm run test:php -- --filter WP_Test_REST_Collaboration_Server

# E2E tests — 3 concurrent users (presence, sync, undo/redo)
npm run test:e2e -- tests/e2e/specs/collaboration/

Note for beta testers: If upgrading from a previous beta, the old wp_sync_updates table is no longer used and can be dropped: npm run env:cli -- db query "DROP TABLE IF EXISTS wp_sync_updates"

Use of AI Tools

Co-authored with Claude Code (Opus 4.6), used to synthesize discussion across related tickets and PRs into a single implementation. All code was reviewed and tested before submission.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Introduces the wp_collaboration table for storing real-time editing
data (document states, awareness info, undo history) and the
WP_Collaboration_Table_Storage class that implements all CRUD
operations against it. Bumps the database schema version.
Replaces WP_HTTP_Polling_Sync_Server with
WP_HTTP_Polling_Collaboration_Server using the wp-collaboration/v1
REST namespace. Switches to string-based client IDs, fixes the
compaction race condition, and uses UPDATE-then-INSERT for
awareness data.
Deletes WP_Sync_Post_Meta_Storage and WP_Sync_Storage interface,
and removes the wp_sync_storage post type registration from post.php.
These are superseded by the dedicated collaboration table.
Adds wp_is_collaboration_enabled() gate, injects the collaboration
setting into the block editor, registers cron event for cleaning up
stale collaboration data, and updates require/include paths for the
new storage and server classes.
Registers a duplicate REST route under the wp-sync/v1 namespace so
that the Gutenberg plugin's bundled sync package continues to work
against WordPress 7.0+.
Adds 67 tests for WP_HTTP_Polling_Collaboration_Server covering
document sync, awareness, undo/redo, compaction, permissions, and
the backward-compatible wp-sync/v1 route. Removes the old sync
server tests. Updates REST schema setup and settings controller
tests for the new collaboration endpoints and setting.
Adds end-to-end tests for real-time collaboration covering presence
indicators, document synchronization across browser contexts, and
collaborative undo/redo behavior. Includes shared test utilities
and fixtures.
@josephfusco josephfusco changed the title Collaboration: Replace post meta storage with dedicated database table - wp_collaboration Collaboration: Replace post meta storage with dedicated database table Mar 14, 2026
@josephfusco josephfusco changed the title Collaboration: Replace post meta storage with dedicated database table Collaboration: Replace post meta storage with dedicated database table Mar 14, 2026
@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

josephfusco and others added 4 commits March 14, 2026 17:21
Increment $wp_db_version from 61833 to 61834 so the upgrade_700()
routine triggers dbDelta() for the new collaboration table. Add a
PHPUnit test covering the backward-compatible wp-sync/v1 route alias,
including a $_namespace parameter on the dispatch_collaboration helper.
Fix stale changes in default-filters.php that were carried over from
the old branch during the rewrite. Restores the Connectors API init
hook, login_head resource hints action, wp_default_styles hook for
classic theme block styles, and admin_init hook for collaboration
setting injection.
Clarify that the $_namespace parameter defaults to the primary
namespace, matching Weston's suggestion from PR 11068 review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant