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

Add `wp user spam` command #74

Merged
merged 13 commits into from Sep 8, 2017

Conversation

3 participants
@BhargavBhandari90
Contributor

BhargavBhandari90 commented Sep 2, 2017

Command:

  • wp user spam 123

For : #50

BhargavBhandari90 added some commits Sep 2, 2017

Add command for user marked as a spam
Command:
- wp user spam 123
Add some validations while reporting user as spam
Validations:
- If user is super-user, then don't set as spam
- Show warning if user is already reported as spam

@BhargavBhandari90 BhargavBhandari90 changed the title from WIP: Add command for user marked as a spam to Add command for user marked as a spam Sep 2, 2017

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001

miya0001 Sep 3, 2017

Member

I think we shouldn't try to use SQL as much as possible.
Can you use update_user_status() or so?

Member

miya0001 commented Sep 3, 2017

I think we shouldn't try to use SQL as much as possible.
Can you use update_user_status() or so?

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 3, 2017

Contributor

yes, @miya0001 I just saw that function. Applying that only.

Contributor

BhargavBhandari90 commented Sep 3, 2017

yes, @miya0001 I just saw that function. Applying that only.

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001
Member

miya0001 commented Sep 3, 2017

Thanks @BhargavBhandari90 😄

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 3, 2017

Contributor

Behat test for user.feature shows following error for spam command

PHP Fatal error: Call to undefined function get_network() in src/User_Command.php on line 1064
Fatal error: Call to undefined function get_network() in src/User_Command.php on line 1064
cwd: /tmp/wp-cli-test-run-user-test.feature.3-59abbe9ab397d9.99056625/
exit status: 255

However, I am not getting this error while running command into the terminal.

So I am confused, is my code has something wrong or what?

Contributor

BhargavBhandari90 commented Sep 3, 2017

Behat test for user.feature shows following error for spam command

PHP Fatal error: Call to undefined function get_network() in src/User_Command.php on line 1064
Fatal error: Call to undefined function get_network() in src/User_Command.php on line 1064
cwd: /tmp/wp-cli-test-run-user-test.feature.3-59abbe9ab397d9.99056625/
exit status: 255

However, I am not getting this error while running command into the terminal.

So I am confused, is my code has something wrong or what?

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001
Member

miya0001 commented Sep 3, 2017

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 3, 2017

Contributor

@miya0001 Yes, see I just did that. That was real time 😛 Thank you for giving your time.

Contributor

BhargavBhandari90 commented Sep 3, 2017

@miya0001 Yes, see I just did that. That was real time 😛 Thank you for giving your time.

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001

miya0001 Sep 3, 2017

Member

Hi,

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.
But I guess your implementation will return 0.

We need consistency between same commands, so following is a good example to handle multiple arguments.

Member

miya0001 commented Sep 3, 2017

Hi,

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.
But I guess your implementation will return 0.

We need consistency between same commands, so following is a good example to handle multiple arguments.

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 3, 2017

Contributor

ok. Checking this.

Contributor

BhargavBhandari90 commented Sep 3, 2017

ok. Checking this.

@miya0001 miya0001 added this to the 1.1.0 milestone Sep 3, 2017

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 3, 2017

Contributor

One test is failing. because I used a function which was not available in that WP version.
How to tackle that situation?

Here is the error https://travis-ci.org/wp-cli/entity-command/jobs/271378052

Contributor

BhargavBhandari90 commented Sep 3, 2017

One test is failing. because I used a function which was not available in that WP version.
How to tackle that situation?

Here is the error https://travis-ci.org/wp-cli/entity-command/jobs/271378052

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001

miya0001 Sep 3, 2017

Member

Do you want to use get_network() to mark spam the user's site too?
I guess there is a good example. :)
https://github.com/wp-cli/entity-command/blob/master/src/Site_Command.php#L749-L766

Member

miya0001 commented Sep 3, 2017

Do you want to use get_network() to mark spam the user's site too?
I guess there is a good example. :)
https://github.com/wp-cli/entity-command/blob/master/src/Site_Command.php#L749-L766

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 5, 2017

Contributor

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.
But I guess your implementation will return 0.

@miya0001 As you said we need wp user unspam for this. So I will implement this.

Contributor

BhargavBhandari90 commented Sep 5, 2017

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.
But I guess your implementation will return 0.

@miya0001 As you said we need wp user unspam for this. So I will implement this.

BhargavBhandari90 added some commits Sep 6, 2017

Add unspam user command
- made a common function for updating user data
@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 6, 2017

Contributor

Hi @miya0001

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.

I have implemented this thing. But I don't know how to get return code so that I can add it into feature file.

Currently, I am not adding that line into users.feature.

Contributor

BhargavBhandari90 commented Sep 6, 2017

Hi @miya0001

If wp user spam is passed multiple arguments and there is an error from one of them, then status code should be 1.

I have implemented this thing. But I don't know how to get return code so that I can add it into feature file.

Currently, I am not adding that line into users.feature.

@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001

miya0001 Sep 6, 2017

Member

@BhargavBhandari90

Please write test like following.

When I try `wp user spam {BBEE_ID} 9999`
Then STERR should contain:
  """
  Warning: User 9999 doesn't exist.
  """
And the return code should be 1
Member

miya0001 commented Sep 6, 2017

@BhargavBhandari90

Please write test like following.

When I try `wp user spam {BBEE_ID} 9999`
Then STERR should contain:
  """
  Warning: User 9999 doesn't exist.
  """
And the return code should be 1
@miya0001

This comment has been minimized.

Show comment
Hide comment
@miya0001

miya0001 Sep 6, 2017

Member

Ah, sorry, it should be like following.

When I try `wp user spam {BBEE_ID} 9999`
Then STOUT should contain:
  """
  User {BBEE_ID} marked as spam.
  """
And STOUT should contain:
  """
  Warning: User 9999 doesn't exist.
  """
And the return code should be 1
Member

miya0001 commented Sep 6, 2017

Ah, sorry, it should be like following.

When I try `wp user spam {BBEE_ID} 9999`
Then STOUT should contain:
  """
  User {BBEE_ID} marked as spam.
  """
And STOUT should contain:
  """
  Warning: User 9999 doesn't exist.
  """
And the return code should be 1
@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Sep 8, 2017

Contributor

@miya0001 This should be fine now.

Contributor

BhargavBhandari90 commented Sep 8, 2017

@miya0001 This should be fine now.

Show outdated Hide outdated src/User_Command.php Outdated
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Sep 8, 2017

Member

The grammar is off for the batch results, but this needs to be fixed in WP_CLI\Utils. I've opened an issue for this here: wp-cli/wp-cli#4338

Member

schlessera commented Sep 8, 2017

The grammar is off for the batch results, but this needs to be fixed in WP_CLI\Utils. I've opened an issue for this here: wp-cli/wp-cli#4338

@schlessera schlessera changed the title from Add command for user marked as a spam to Add `wp user spam` command Sep 8, 2017

@schlessera schlessera merged commit 49df45f into wp-cli:master Sep 8, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera
Member

schlessera commented Sep 8, 2017

Thanks, @BhargavBhandari90 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment