Open ton31337 opened 6 months ago
Copied over from #261 :
@ton31337 This is just one of many places where directly passing sensitive information can be leaked into the process list or similar, so adding environment variables for these is not really scalable.
As @danielbachhuber mentioned, WP-CLI supports file-based approaches to solve this in a more generic way:
core install:
admin_password: 123456
You can then point your WP-CLI execution to a custom location for that file if you generate it dynamically:
WP_CLI_CONFIG_PATH=/path/to/custom/wp-cli.yml wp core install
You can let WP-CLI require an additional PHP file that gets executed from within the context of WP-CLI. This way, you have full control of the entire execution. You can for example hook into the random_password
filter to control what the generated password will be:
<?php
// Hook into the WP-CLI process to act when the `wp core install` command is being triggered.
WP_CLI::add_hook( 'before_invoke:core install', static function() {
// Compute the admin password in whatever way you want.
// This can come from a file, be queried via an API, etc...
$admin_password = '123456';
// Hook into the `random_password` filter to return the computed password.
WP_CLI::add_wp_hook( 'random_password', static function() use ( $admin_password ) {
return $admin_password;
} );
} );
This can be used via the --require=<path-to-script.php>
flag:
wp core install --require=<path/to/script.php>
--require=<path-to-script.php>
to the WP-CLI binary.
The config file would then look like this:
require:
- path/to/script.php
More detailed documentation about:
Feature Request
Describe your use case and the problem you are facing
The context and the problem is defined directly in the commit: https://github.com/wp-cli/core-command/pull/261/commits/a8308bbcf51f1f1b12274176cdd6e0f4233d3c2a.
wp-cli.yml
is not an option, it requires unnecessary operations, creating the file, deleting the file...Describe the solution you'd like
The solution to the current issue is https://github.com/wp-cli/core-command/pull/261.