diff --git a/features/user.feature b/features/user.feature index 1c554fa31..855f962b4 100644 --- a/features/user.feature +++ b/features/user.feature @@ -435,6 +435,15 @@ Feature: Manage WordPress users And I run `wp user get oprime` Then STDOUT should not be empty + When I run `wp site create --slug=foo --porcelain` + Then save STDOUT as {SPAM_SITE_ID} + + When I run `wp --url=example.com/foo user set-role {BBEE_ID} administrator` + Then STDOUT should contain: + """ + Success: + """ + When I run `wp user spam {BBEE_ID}` Then STDOUT should be: """ @@ -453,6 +462,18 @@ Feature: Manage WordPress users """ And the return code should be 0 + When I run `wp site list --site__in=1 --field=spam` + Then STDOUT should be: + """ + 0 + """ + + When I run `wp site list --site__in={SPAM_SITE_ID} --field=spam` + Then STDOUT should be: + """ + 1 + """ + When I try `wp user spam {OP_ID} 9999` Then STDOUT should be: """ @@ -466,6 +487,24 @@ Feature: Manage WordPress users """ And the return code should be 1 + When I run `wp user unspam {BBEE_ID}` + Then STDOUT should contain: + """ + Success: + """ + + When I run `wp site list --site__in=1 --field=spam` + Then STDOUT should be: + """ + 0 + """ + + When I run `wp site list --site__in={SPAM_SITE_ID} --field=spam` + Then STDOUT should be: + """ + 0 + """ + @require-wp-4.3 Scenario: Sending emails on update Given a WP install diff --git a/src/User_Command.php b/src/User_Command.php index d77774680..8165c9e64 100644 --- a/src/User_Command.php +++ b/src/User_Command.php @@ -2,7 +2,6 @@ use WP_CLI\CommandWithDBObject; use WP_CLI\Entity\Utils as EntityUtils; -use WP_CLI\Fetchers\Site as SiteFetcher; use WP_CLI\Fetchers\User as UserFetcher; use WP_CLI\Formatter; use WP_CLI\Iterators\CSV as CsvIterator; @@ -51,8 +50,7 @@ class User_Command extends CommandWithDBObject { ]; public function __construct() { - $this->fetcher = new UserFetcher(); - $this->sitefetcher = new SiteFetcher(); + $this->fetcher = new UserFetcher(); } /** @@ -1251,10 +1249,8 @@ private function update_msuser_status( $user_ids, $pref, $value ) { // Make that user's blog as spam too. $blogs = (array) get_blogs_of_user( $user_id, true ); foreach ( $blogs as $details ) { - $site = $this->sitefetcher->get_check( $details->site_id ); - - // Main blog shouldn't a spam ! - if ( $details->userblog_id !== $site->blog_id ) { + // Only mark site as spam if not main site. + if ( ! is_main_site( $details->userblog_id, $details->site_id ) ) { update_blog_status( $details->userblog_id, $pref, $value ); } }