Automatic Password generation on Install does not work#3573
Merged
Conversation
…g wp core install.
Member
|
Sorry about that — thanks for the fix! |
Author
|
No problem; I'm writing some automated install tasks and kept getting tripped up by why the password being generated wasn't letting me log in! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#3535 was recently done to allow for a default password to be generated using
wp core install. However, it does not appear to correctly install the generated password in the system, as the admin user is unable to log in after the install has completed using the randomly generated password.I did some digging, and the problem is that in https://github.com/wp-cli/wp-cli/blob/master/php/commands/core.php#L673 the
extractoccurs with a blank value, and the subsequent Admin Password is set to the$assoc_argsarray...which has already had its values extracted. So the blank value already in$assoc_args['admin_password']which is now set to$admin_passwordgets passed intowp_install()on line 699, instead of the randomly generated password..The fix is to simply move the block up from line https://github.com/wp-cli/wp-cli/blob/master/php/commands/core.php#L686 to above the extract at line 673.
Better yet, however, is the pull request submitted which lets
wp_installhandle the password generation by default (see https://developer.wordpress.org/reference/functions/wp_install/), and prints out the returned generated password that's in$result['password']. This ensures that we follow Wordpress best practices, and keep up to date changes submitted from Wordpress without modifying the local codebase.