New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error and prevent deleting root site #73
Changes from 3 commits
86a084c
2fa9d0b
a89f6fb
9f79413
abae414
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,7 +265,12 @@ function delete( $args, $assoc_args ) { | |
|
||
$site_url = trailingslashit( $blog->siteurl ); | ||
|
||
WP_CLI::confirm( "Are you sure you want to delete the '$site_url' site?", $assoc_args ); | ||
if ( $blog_id == BLOG_ID_CURRENT_SITE && ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'delete-root' ) ) { | ||
WP_CLI::line( WP_CLI::colorize( "%R'$site_url' is the root site. Pass the --delete-root flag to delete it.%n" ), $assoc_args ); | ||
return; | ||
} else { | ||
WP_CLI::confirm( "Are you sure you want to delete the '$site_url' site?", $assoc_args ); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given we already have a confirmation prompt before deleting a site, I don't think it's necessary to require another flag to delete the root site. Instead, when deleting the root site we should customize the confirmation message to indicate what happens when you delete the root site. As currently implemented, this would be a breaking change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a scenario as:
Following observations have been made after executing
Irrelevant of the fact that whether you want to keep/drop tables, the users will get deleted as evident here |
||
|
||
wpmu_delete_blog( $blog->blog_id, ! \WP_CLI\Utils\get_flag_value( $assoc_args, 'keep-tables' ) ); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use is_main_site here