Opened 8 years ago
Closed 4 years ago
#40145 closed defect (bug) (worksforme)
Revisions sent to trash never get deleted by WordPress
Reported by: | programmin | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | |
Component: | Revisions | Keywords: | has-patch reporter-feedback |
Focuses: | Cc: |
Description
If you remove an autosave of a page like so:
<?php $autosave = wp_get_post_autosave( id ) wp_trash_post($autosave->ID);
it actually gets in the database such that it will never be removed, even if you empty trash of posts and pages later.
You can see all the revisions it wants to leave forever with:
SELECT * FROM wordpress.wp_posts where post_status = 'trash' and post_type = 'revision' order by id desc;
Attachments (4)
Change History (11)
#1
@
7 years ago
- Keywords needs-patch added
- Summary changed from Revisions sent to trash never get deleted by Wordpress. to Revisions sent to trash never get deleted by WordPress
- Version trunk deleted
#2
@
5 years ago
- Keywords has-patch added; needs-patch removed
The patch is quite simple, just check if the given post is a revision, if so, we remove it in the database
#3
@
5 years ago
@adamsilverstein @karmatosed Hello, if you could have a look since you are component maintainers for post revisions, it would be highly appreciated :)
#4
@
5 years ago
- Component changed from Posts, Post Types to Revisions
- Keywords reporter-feedback added
- Owner set to adamsilverstein
- Severity changed from normal to minor
- Status changed from new to assigned
Hello @Mista-Flo - thanks for the ping and the bug report.
I attempted to reproduce this and was unable to.
Here is what I tried (I am testing against trunk):
- Empty database and create a new post.
- Publish post, make some changes to trigger an autosave and exit the post exit screen.
At this point I have three records in the database post table: one for the post itself, one for a revision created of the initial save, and one autosave
The I opened wp-cli shell and issued the commands from the ticket description:
$autosave = wp_get_post_autosave( [post id] );
wp_trash_post($autosave->ID);
Checking the database I see that the autosave record was removed:
I tried again with the ID of one of the revisions and again the record was correctly deleted:
Perhaps I have missed some step to reproduce? What version of WordPress are you using when you see this issue?
Can you please try again on your end first disabling all plugins and also switching to a default theme like twentynineteen if possible to eliminate the possibility that a plugin or theme code is affecting autosaves.
#5
@
5 years ago
@programmin or @Mista-Flo can you add any steps to reproduce this issue? See comment above https://core.trac.wordpress.org/ticket/40145#comment:4
#7
@
4 years ago
- Milestone Awaiting Review deleted
- Resolution set to worksforme
- Status changed from assigned to closed
@Mista-Flo I'm going to go ahead and close this as it "Works for me" - I was unable to reproduce the issue. Perhaps you had some temporary issue that caused this to happen?
If you feel that I have missed something and are able to reproduce, please feel free to re-open this ticket.
First patch