Skip to content

Use current_time() for setting the default value for user_registered in wp user create#378

Merged
danielbachhuber merged 2 commits intowp-cli:masterfrom
jorgeatorres:master
Oct 3, 2022
Merged

Use current_time() for setting the default value for user_registered in wp user create#378
danielbachhuber merged 2 commits intowp-cli:masterfrom
jorgeatorres:master

Conversation

@jorgeatorres
Copy link
Contributor

@jorgeatorres jorgeatorres commented Oct 1, 2022

This PR fixes issue #377, by relying on current_time() instead of date_format() to properly produce a default value for user_registered when creating users via wp user create.

I've also included a behat test that should fail in master (but not on this branch).

Note: I did a quick search through the org and this seems to be the only place where we were using date_format() with an invalid format.

Steps to test

  1. Check out master.
  2. Run wp user create testuser testuser@example.com.
  3. Check that wp user get testuser shows 0000-00-00 00:00:00 as the value for the user_registered field.
  4. Delete the user created in step 2. For example, with wp user delete testuser.
  5. Check out this branch.
  6. Repeat step 2 and confirm that this time the current date/time is the value of the user_registered field.

Closes #377.

@jorgeatorres jorgeatorres requested a review from a team as a code owner October 1, 2022 21:00
@danielbachhuber danielbachhuber added bug command:user-create Related to 'user create' command labels Oct 3, 2022
Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @jorgeatorres ! I appreciate your detailed description 😊

@danielbachhuber danielbachhuber added this to the 2.3.3 milestone Oct 3, 2022
@danielbachhuber danielbachhuber merged commit f1bc9cc into wp-cli:master Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:user-create Related to 'user create' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wp user create with no --user_registered arg creates users with invalid registration date

2 participants