Repository navigation
Revisions: Store the restored meta in the revision of a restore - #16314
adamsilverstein wants to merge 2 commits into
Conversation
Restoring a revision stores a new revision that holds the restored content and the footnotes from before the restore. The test fails until that is fixed. See #66859.
`wp_restore_post_revision()` updated the post, which stored a new revision, before the `wp_restore_post_revision` action restored the revisioned meta. The new revision was left with the meta from before the restore, and a restore that only changed meta stored no revision at all. Fire the after-insert hooks once the meta is restored, as the REST API does when it updates a post, so that the revision is stored with the restored meta. Fixes #66859.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟡 Changes recommended
The attachment restore path still fires wp_after_insert_post during wp_insert_attachment and again afterward, potentially storing a revision before metadata restoration and violating the required single post-restore hook invocation.
1 open issue
What changed in this PR
Updates revision restoration so the newly stored revision captures restored post metadata, including footnotes, while ensuring metadata-only restores create a revision.
Changes:
- Defers
wp_after_insert_postuntil after revisioned metadata is restored. - Adds PHPUnit coverage for restored metadata, metadata-only restores, and hook ordering.
- Adds an end-to-end footnotes regression test covering the admin restore flow and REST revision data.
| File | Description |
|---|---|
| tests/phpunit/tests/post/metaRevisions.php | Adds PHPUnit tests for restored revision metadata, metadata-only restores, and wp_after_insert_post behavior. |
| tests/e2e/specs/restore-revision-footnotes.test.js | Adds an end-to-end test verifying restored footnotes through the revisions interface and REST API. |
| src/wp-includes/revision.php | Adjusts revision restoration sequencing so restored metadata is applied before the resulting revision and post-insert hook are processed. |
Review effort: Lite

Trac ticket: https://core.trac.wordpress.org/ticket/66859
Claude Code (Fable 5.2) wrote the tests, the fix and this description:
AI Use
Claude Code (Fable 5.2) found the cause, wrote the tests and the fix, and drafted this description. I will review and test.
🤖 Generated with Claude Code