Repository navigation
Fix: Clear trash meta when a post leaves the Trash through a save. - #16214
jorgefilipecosta wants to merge 1 commit into
Conversation
…ugh a save. When a post leaves the Trash through a save instead of `wp_untrash_post()`, its trash meta stays and the comments trashed with it stay trashed. Trashing it again adds a second `_wp_trash_meta_status` value. `wp_insert_post()` now clears the trash meta and restores the comments the way `wp_untrash_post()` does, to fix possible inconsistencies. `wp_trash_post()` now uses `update_post_meta()` for the trash meta. See #66809.
|
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. |
| * and that the comments trashed with it are restored. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * and that its comments stay trashed. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * stores only its latest status. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * Tests that wp_trash_post() replaces trash meta left on a post that is not in the Trash. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * after the post leaves the Trash. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * and that the comments trashed with it are restored. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
| * stores only its latest status. | ||
| * | ||
| * @ticket 66809 | ||
| * @since 7.3.0 |
There was a problem hiding this comment.
| * @since 7.3.0 |
Found while working on #16028.
When a post leaves the Trash through a save instead of
wp_untrash_post(), its trash meta stays and the comments trashed with it stay trashed. Trashing it again adds a second_wp_trash_meta_statusvalue.This PR implements the following changes:
wp_insert_post()clears the trash meta and restores the comments the waywp_untrash_post()does when a post moves fromtrashto another status, to fix possible inconsistencies.wp_untrash_post()deletes the trash meta before it updates the post, so the new code does not run for it.wp_trash_post()usesupdate_post_meta()for_wp_trash_meta_statusand_wp_trash_meta_time.Drafted with AI assistance (Claude Code) and reviewed by me.
Trac ticket: https://core.trac.wordpress.org/ticket/66809
Testing
Verify the unit tests are passing:
I also ran the snippet from the ticket and verified the meta is empty and the comment is approved again.