Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#32933 closed enhancement (fixed)

Allow pre-delete bailout in `wp_delete_post()`

Reported by: boonebgorges's profile boonebgorges Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:


I've worked on a number of custom projects where post deletion is a resource-intensive process - such as when posts are arranged hierarchically, and deleting an item deletes the entire tree. In these cases, I've written custom delete routines that create a queue and then delete from the queue in batches. This generally works OK.

The problem is that when an item is queued for batch deletion, I want to prevent its deletion in other contexts: specifically, bulk actions on edit.php and Empty Trash. Currently, there's no way to do this, short of intercepting and modifying $_REQUEST.

It'd be nice if there was a way to bail out of post deletion, no matter which interface is the origin of the deletion. The attached patch suggests one way, modeled on the *_metadata() 'pre_' filters.

Attachments (1)

32933.diff (798 bytes) - added by boonebgorges 8 years ago.

Download all attachments as: .zip

Change History (3)

8 years ago

#1 @wonderboymusic
8 years ago

  • Milestone changed from Awaiting Review to 4.4

#2 @wonderboymusic
8 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 34082:

wp_delete_post(): add a filter, 'pre_delete_post', to allow bailout from the function if the filter returns a non-null value.

Props boonebgorges.
Fixes #32933.

Note: See TracTickets for help on using tickets.