Opened 4 years ago
Closed 10 months ago
#25584 closed enhancement (fixed)
Add an action hook at the end of wpmu_delete_blog
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.8 | Priority: | normal |
| Severity: | normal | Version: | 3.0 |
| Component: | Networks and Sites | Keywords: | has-patch commit |
| Focuses: | multisite | Cc: |
Description
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 (4)
Change History (24)
#1
@SergeyBiryukov
4 years ago
- Milestone changed from Awaiting Review to 3.8
- Type changed from feature request to enhancement
#2
@SergeyBiryukov
4 years ago
- Keywords has-patch added
@jeremyfelt
4 years ago
#3
@jeremyfelt
4 years ago
#4
@SergeyBiryukov
4 years ago
- Keywords commit added
#5
@DrewAPicture
4 years 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 hooks would remain in the name of posterity and back-compat. I think either situation (renaming or not renaming the function), I'd prefer the hooks match. That's just me.
#6
@nacin
4 years 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.
@jeremyfelt
4 years ago
#7
@jeremyfelt
4 years 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.
#8
@DrewAPicture
4 years ago
+1 for 25584.2.diff.
#9
@pauldewouters
4 years ago
thanks for the improvements
#10
@jeremyfelt
4 years ago
- Component changed from Multisite to Networks and Sites
- Focuses multisite added
#11
@jeremyfelt
4 years ago
- Keywords commit added
25584.2.diff still applies cleanly. Adds deleted_blog filter with docs.
#12
@DrewAPicture
4 years ago
The hook docs in 25584.2.diff look great. Let's do this thing.
#13
@nacin
4 years 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).
#14
@virgodesign
4 years ago
+1 for this request.
#15
@wonderboymusic
2 years ago
- Keywords commit removed
#16
@johnjamesjacoby
10 months ago
- Keywords needs-refresh added; 2nd-opinion removed
- Milestone changed from Future Release to 4.8
- Owner set to jeremyfelt
- Status changed from new to assigned
- Version set to 3.0
I also just ran into a need for this.
Core already has deleted_post and deleted_user, so the proposed deleted_blog action makes sense.
I'm -1 on naming it deleted_site for the reasons @DrewAPicture stated.
@johnjamesjacoby
10 months ago
Move action outside of $drop check and pass $drop as a parameter to match delete_blog usage
#17
@johnjamesjacoby
10 months ago
- Keywords commit added; needs-refresh removed
This ticket was mentioned in Slack in #core-multisite by jjj. View the logs.
10 months ago
#19
@jeremyfelt
10 months ago
25584.3.diff looks good. I think it makes sense adding this to help with other cleanup related operations. If we ever redo this function, it will likely be very different and have different actions.
#20
@jeremyfelt
10 months ago
- Resolution set to fixed
- Status changed from assigned to closed
In 40351:
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.