Skip to content
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

Directly pass empty or missing password parameter to WordPress #232

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

Souptik2001
Copy link
Contributor

Issue

  • WP-CLI overrides default WP password when no password is set #183
  • If the --admin_password parameter is missing or an empty value is passed while executing core install commands, the password should not be generated on WP-CLI command side, rather should be passed as it is to wp_install() for WordPress to internally generate it, which in that case will also send the auto-generated password through the new blog email to the admin user.

Testing

In the current tests email content is not tested. Therefore didn't attach a test for this change. Please let me know if a test is needed.

"New Blog" email before and after the change

Before the change even if password is not supplied through parameter and random password is generated, it is not send through email -

image

But after the change, if random password is generated then that is send through the email -

image

To ensure WordPress auto-generates the password and can send the
password to the user through email.

Signed-off-by: Souptik Datta <souptikdatta2001@gmail.com>
@Souptik2001 Souptik2001 requested a review from a team as a code owner May 22, 2023 21:36
@swissspidy swissspidy linked an issue Aug 24, 2023 that may be closed by this pull request
@salcode
Copy link

salcode commented Aug 24, 2023

This approach looks good. 👍

$args['admin_password'] is guaranteed to be defined as a string, because a default value of empty string ("") is set in this block of code (the case of it being undefined was my initial concern looking at this PR, so I wanted to include this note in case anyone else has the same thoughts).

$defaults = [
'title' => '',
'admin_user' => '',
'admin_email' => '',
'admin_password' => '',
];
if ( Utils\wp_version_compare( '4.0', '<' ) ) {
if ( array_key_exists( 'locale', $assoc_args ) ) {
WP_CLI::warning(
sprintf(
'The flag --locale=%s is being ignored as it requires WordPress 4.0+.',
$assoc_args['locale']
)
);
}
} else {
$defaults['locale'] = '';
}
$args = wp_parse_args( $assoc_args, $defaults );

Do we want to add any tests to this PR?
(I'm not sure what tests would look like 🤔 )

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.

Thanks for working on this @Souptik2001 , and thanks for testing @salcode !

@danielbachhuber danielbachhuber merged commit 0852e36 into wp-cli:main Aug 24, 2023
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment