Make WordPress Core

Opened 18 months ago

Last modified 9 months ago

#25584 new enhancement

Add an action hook at the end of wpmu_delete_blog

Reported by: pauldewouters Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch commit 2nd-opinion
Focuses: multisite Cc:


I have the need of an additional hook in the wpmu_delete_blog function in wp-admin/includes/ms.php.

I'm maintaining a list of active blogs in a DB option which also has extra data associated. I update this list on 2 hooks currently: wpmu_new_blog and delete_blog

Unfortunately, the delete_blog occurs before the actual blog deletion, so at that point, an SQL query will return that blog too.

If there were a hook after the actual deletion, I could retrieve the list of active blogs.

Attachments (3)

ms.diff (399 bytes) - added by pauldewouters 18 months ago.
25584.diff (504 bytes) - added by jeremyfelt 17 months ago.
25584.2.diff (504 bytes) - added by jeremyfelt 16 months ago.

Download all attachments as: .zip

Change History (17)

@pauldewouters18 months ago

comment:1 @SergeyBiryukov17 months ago

  • Milestone changed from Awaiting Review to 3.8
  • Type changed from feature request to enhancement

comment:2 @SergeyBiryukov17 months ago

  • Keywords has-patch added

@jeremyfelt17 months ago

comment:3 @jeremyfelt17 months ago

25584.diff is slightly different from the original patch. I think deleted_site aligns with the naming of some other hooks in core. Docs for the hook have also been updated to reflect the proper version for @since.

comment:4 @SergeyBiryukov17 months ago

  • Keywords commit added

comment:5 @DrewAPicture17 months ago

  • Keywords dev-feedback added

Worth noting that the parent function is named wpmu_delete_blog, and this hook would be preceded by a delete_blog hook. So perhaps in the name of consistency we should go with deleted_blog vs deleted_site.

If at some time in the future the parent function gets renamed to say, wp_delete_site, I'd imagine the hook would remain in the name of posterity and back-compat. I think either situation (renaming or renaming the function), I'd prefer the hooks match. That's just me.

Version 1, edited 17 months ago by DrewAPicture (previous) (next) (diff)

comment:6 @nacin16 months ago

  • Keywords commit dev-feedback removed
  • Milestone changed from 3.8 to Future Release

I'd tend to agree with keeping the hooks the same style.

@jeremyfelt16 months ago

comment:7 @jeremyfelt16 months ago

  • Milestone changed from Future Release to 3.9

25584.2.diff is a refresh for 3.9, goes with deleted_blog as the filter.

comment:9 @pauldewouters16 months ago

thanks for the improvements

comment:10 @jeremyfelt14 months ago

  • Component changed from Multisite to Networks and Sites
  • Focuses multisite added

comment:11 @jeremyfelt13 months ago

  • Keywords commit added

25584.2.diff still applies cleanly. Adds deleted_blog filter with docs.

comment:12 @DrewAPicture13 months ago

The hook docs in 25584.2.diff look great. Let's do this thing.

Last edited 13 months ago by DrewAPicture (previous) (diff)

comment:13 @nacin13 months ago

  • Keywords 2nd-opinion added
  • Milestone changed from 3.9 to Future Release

This filter is inside a if ( $drop ) conditional which means it would only be fired when data is actually deleted.

I'll be honest, I don't see much of a purpose for this hook. The existing delete_blog action is enough, even though it is on pre-transaction. If you're trying to query only active blogs, simply exclude the blog for which the hook has fired. While we would generally provide and benefit from a post-transaction hook, I'd hesitate to bother adding one until we re-do this function at some point down the line (with better terminology and less hackery).

comment:14 @virgodesign9 months ago

+1 for this request.

Note: See TracTickets for help on using tickets.