Skip to content

RTC: Backport fix to prevent autosaves from losing content.#11691

Open
dmsnell wants to merge 6 commits intoWordPress:trunkfrom
dmsnell:fix/rtc-autodraft-autosave-loss-pr
Open

RTC: Backport fix to prevent autosaves from losing content.#11691
dmsnell wants to merge 6 commits intoWordPress:trunkfrom
dmsnell:fix/rtc-autodraft-autosave-loss-pr

Conversation

@dmsnell
Copy link
Copy Markdown
Member

@dmsnell dmsnell commented May 1, 2026

Trac ticket: Core-65138

This is a companion change to WordPress/gutenberg#77865.

An interaction with autosave can cause posts and revisions to get lost even when a single user is editing a post.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

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.

@dmsnell dmsnell force-pushed the fix/rtc-autodraft-autosave-loss-pr branch from dcb12a8 to 0db23e4 Compare May 5, 2026 18:52
dmsnell added a commit to WordPress/gutenberg that referenced this pull request May 5, 2026
…sions to avoid post loss.

Trac ticket: Core-65138
Follow-up to #75105
Part of #77716
See Core backport in WordPress/wordpress-develop#11691

When an RTC session in the editor saves edits on a draft post, they always save into an autosave revision. This prevents a sync but where storing to the post itself would lead to duplicate edits. This was set in 9df142b. However, there is an exception to this rule: the first session to save edits needs to promote the autosave revision into a real draft post, if a post doesn’t exist. The reason is that WordPress hides autosaves.

That is, multiple people could be editing a draft post and then once they close it, never be able to find it again. While the data is still in the database, this is a loss of the post from a practical standpoint.

This change introduces an exception where the first time a collaborative session is saving draft edits, the autodraft is promoted to a real draft post, making it visible in the post list.

Developed in: #77865
Backport in: WordPress/wordpress-develop#11691
Trac ticket: https://core.trac.wordpress.org/ticket/65138

Co-authored-by: danluu <danluu@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
peterwilsoncc pushed a commit to peterwilsoncc/gutenberg-build that referenced this pull request May 5, 2026
…sions to avoid post loss.

Trac ticket: Core-65138
Follow-up to #75105
Part of #77716
See Core backport in WordPress/wordpress-develop#11691

When an RTC session in the editor saves edits on a draft post, they always save into an autosave revision. This prevents a sync but where storing to the post itself would lead to duplicate edits. This was set in 9df142b839320316b406ee1a02e23704d42f8719. However, there is an exception to this rule: the first session to save edits needs to promote the autosave revision into a real draft post, if a post doesn’t exist. The reason is that WordPress hides autosaves.

That is, multiple people could be editing a draft post and then once they close it, never be able to find it again. While the data is still in the database, this is a loss of the post from a practical standpoint.

This change introduces an exception where the first time a collaborative session is saving draft edits, the autodraft is promoted to a real draft post, making it visible in the post list.

Developed in: WordPress/gutenberg#77865
Backport in: WordPress/wordpress-develop#11691
Trac ticket: https://core.trac.wordpress.org/ticket/65138

Co-authored-by: danluu <danluu@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>

Source: WordPress/gutenberg@6f328a8
@dmsnell dmsnell marked this pull request as ready for review May 5, 2026 22:28
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @danluu@git.wordpress.org.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dmsnell, cbravobernal.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants