#20305 closed defect (bug) (fixed)
update_blog_status should also handle delete/undelete cases
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Multisite | Version: | 3.2.1 |
| Severity: | normal | Keywords: | dev-feedback has-patch |
| Cc: |
Description
function update_blog_status defined in /includes/ms-blog.php fires the following actions:
... if ( 'spam' == $pref ) ( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) : do_action( 'make_ham_blog', $blog_id ); elseif ( 'mature' == $pref ) ( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id ); elseif ( 'archived' == $pref ) ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); elseif ( 'archived' == $pref ) ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); ...
As you see 'archived' is handled twice, while 'deleted' is not handled at all.
The the code should go as follows:
... if ( 'spam' == $pref ) ( $value == 1 ) ? do_action( 'make_spam_blog', $blog_id ) : do_action( 'make_ham_blog', $blog_id ); elseif ( 'mature' == $pref ) ( $value == 1 ) ? do_action( 'mature_blog', $blog_id ) : do_action( 'unmature_blog', $blog_id ); elseif ( 'archived' == $pref ) ( $value == 1 ) ? do_action( 'archive_blog', $blog_id ) : do_action( 'unarchive_blog', $blog_id ); elseif ( 'deleted' == $pref ) ( $value == 1 ) ? do_action( 'delete_blog', $blog_id ) : do_action( 'undelete_blog', $blog_id ); ...
Please include in the next release. Thank you.
Attachments (3)
Change History (14)
comment:2
Kyrylo
— 15 months ago
Then function update_blog_details defined in /includes/ms-blogs.php handles only changed on spam/ham:
...
// If spam status changed, issue actions.
if ( $details[ 'spam' ] != $current_details[ 'spam' ] ) {
if ( $details[ 'spam' ] == 1 )
do_action( "make_spam_blog", $blog_id );
else
do_action( "make_ham_blog", $blog_id );
}
...
Natural.ly, to be consistent, it should also handle archive/unarchived and delete/undelete.
comment:3
Kyrylo
— 15 months ago
Hence the corresponding code should go into function update_blog_details defined in /includes/ms-blogs.php:
...
// If archived status changed, issue actions.
if ( $details[ 'archived' ] != $current_details[ 'archived' ] ) {
if ( $details[ 'archived' ] == 1 )
do_action( "archive_blog", $blog_id );
else
do_action( "unarchive_blog", $blog_id );
}
// If deleted status changed, issue actions.
if ( $details[ 'deleted' ] != $current_details[ 'deleted' ] ) {
if ( $details[ 'deleted' ] == 1 )
do_action( "make_delete_blog", $blog_id );
else
do_action( "make_undelete_blog", $blog_id );
}
...
comment:6
SergeyBiryukov
— 15 months ago
Related: #14385
comment:7
wonderboymusic
— 9 months ago
- Keywords dev-feedback added
$drop has to be true for tables to drop and this to be irreversible, should users be removed if $drop is false? They are currently.
wonderboymusic
— 9 months ago
comment:8
wonderboymusic
— 9 months ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Awaiting Review to 3.5
comment:10
ryan
— 8 months ago
- Owner set to ryan
- Resolution set to fixed
- Status changed from new to closed
In [22185]:
Just discovered that there is already an action 'delete_blog', which is triggered in function wpmu_delete_blog defined in /wp-admin/includes/ms.php
Thus we need to come up with better and more unique names: