wp-cli / entity-command

Manage WordPress comments, menus, options, posts, sites, terms, and users.
MIT License
100 stars 90 forks source link

Can't use `wp user spam *ID*` on single site installation #412

Closed Rvervuurt closed 8 months ago

Rvervuurt commented 1 year ago

Bug Report

Describe the current, buggy behavior

I'm trying to mark a user as spam with wp user spam *ID*, but I get the error Error: This is not a multisite installation.

Describe how other contributors can replicate this bug

Describe what you would expect as the correct outcome

I expect user 50 to be registered as spam, as the (docs)[https://developer.wordpress.org/cli/commands/user/spam/] make me think it should, no matter if it's a multiste or not.

Let us know what environment you are running this on

OS: Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
Shell:  /bin/zsh
PHP binary: /opt/homebrew/Cellar/php@8.1/8.1.21/bin/php
PHP version:    8.1.21
php.ini used:   /opt/homebrew/etc/php/8.1/php.ini
MySQL binary:
MySQL version:
SQL modes:
WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:  phar://wp-cli.phar/vendor
WP_CLI phar path:   /Applications/MAMP/htdocs/ideal/wordpress
WP-CLI packages dir:
WP-CLI cache dir:   /Users/robbert/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.8.1

Provide additional context/Screenshots

image
danielbachhuber commented 1 year ago

Hey @Rvervuurt,

The concept of marking a user as spam only exists in WordPress multisite:

Multisite

image

Standard

image

Whenever relevant, WP-CLI emulates wp-admin, so this isn't behavior we'll change.

How would you recommend we improve the documentation? Want to submit a PR with your suggested changes?

https://github.com/wp-cli/entity-command/blob/5c141092e7d0940c27da29408d6b67d9db1d3934/src/User_Command.php#L1214-L1248

Rvervuurt commented 1 year ago

Ah that makes sense! I didn't know it was multisite-only!

There must be other multisite-commands, how are they documented?

danielbachhuber commented 1 year ago

There must be other multisite-commands, how are they documented?

@Rvervuurt That's a good question. They generally aren't explicitly documented as such, but usually have some reference to multisite:

https://github.com/wp-cli/entity-command/blob/5c141092e7d0940c27da29408d6b67d9db1d3934/src/Site_Command.php#L11

We could say something like:

Marks one or more users as spam on multisite.

Or:

Marks one or more users as spam.

Spam users only exist on multisite.

Do you have a preference? Or another suggestion?