[wp-trac] [WordPress Trac] #49532: Clicking "preview" multiple times on a post causes an identical autosave revision to be created and destroyed repeatedly
WordPress Trac
noreply at wordpress.org
Fri Feb 28 14:43:29 UTC 2020
#49532: Clicking "preview" multiple times on a post causes an identical autosave
revision to be created and destroyed repeatedly
--------------------------+------------------------------------
Reporter: inwerpsel | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Revisions | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: rest-api, performance
--------------------------+------------------------------------
Comment (by inwerpsel):
The filter I proposed above resulted in the autosave not being deleted if
the post is permanently deleted. Unfortunately the arguments of the filter
are identical in both that case and the unwanted deletions, so I couldn't
do anything but using $_GET to check if the current request is one for
permanently deleting posts.
{{{#!php
<?php
private function add_filters() {
add_filter('pre_delete_post', [$this,
'do_not_delete_autosave'], 1, 3);
}
public function do_not_delete_autosave( $something = null, $post =
null, $force_delete = null ): ?bool {
if (
$force_delete
|| ( isset( $_GET['action'] ) && $_GET['action']
=== 'delete' )
|| ( isset( $_GET['delete_all'] ) )
|| !preg_match( '/autosave-v\d+$/',
$post->post_name ) ) {
return null;
}
return false;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49532#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list