Skip to content
Draft
10 changes: 10 additions & 0 deletions .readme-partials/USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,16 @@ chmod +x ~/wp-cli/wp
WP_CLI_BIN_DIR=~/wp-cli composer behat
```

#### Project configuration trust

WP-CLI asks for confirmation before acting on directives that can run code or redirect a command, such as `require`, `exec`, `env`, `ssh-args` or SSH aliases, when they come from a project-level `wp-cli.yml` file. Test fixtures create such files all the time and a test run cannot answer an interactive prompt, so the Behat context passes `WP_CLI_TRUST_PROJECT_CONFIG=1` to every command it runs.

Set the `WP_CLI_TRUST_PROJECT_CONFIG` environment variable yourself to override that default for the whole run. Individual scenarios can override it per command:

```gherkin
When I try `WP_CLI_TRUST_PROJECT_CONFIG=false wp cli version`
```

#### Xdebug Step Debugging

Set `WP_CLI_TEST_XDEBUG` to step debug the WP-CLI and WordPress code that the scenarios run, with Xdebug 3:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,16 @@ chmod +x ~/wp-cli/wp
WP_CLI_BIN_DIR=~/wp-cli composer behat
```

#### Project configuration trust

WP-CLI asks for confirmation before acting on directives that can run code or redirect a command, such as `require`, `exec`, `env`, `ssh-args` or SSH aliases, when they come from a project-level `wp-cli.yml` file. Test fixtures create such files all the time and a test run cannot answer an interactive prompt, so the Behat context passes `WP_CLI_TRUST_PROJECT_CONFIG=1` to every command it runs.

Set the `WP_CLI_TRUST_PROJECT_CONFIG` environment variable yourself to override that default for the whole run. Individual scenarios can override it per command:

```gherkin
When I try `WP_CLI_TRUST_PROJECT_CONFIG=false wp cli version`
```

#### Xdebug Step Debugging

Set `WP_CLI_TEST_XDEBUG` to step debug the WP-CLI and WordPress code that the scenarios run, with Xdebug 3:
Expand Down
8 changes: 8 additions & 0 deletions src/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ private static function get_process_env_variables(): array {
}
}

// Test fixtures routinely create project-level `wp-cli.yml` files that contain
// `require`, `exec`, `env` or `ssh-args` directives. WP-CLI gates those behind a
// trust confirmation, which cannot be answered in a non-interactive test run, so
// trust them by default. Scenarios that specifically test the trust mechanism can
// still override this by prefixing their command with their own value.
$trust_project_config = getenv( 'WP_CLI_TRUST_PROJECT_CONFIG' );
$env['WP_CLI_TRUST_PROJECT_CONFIG'] = false !== $trust_project_config ? $trust_project_config : '1';

$env = array_filter(
array_merge( $env, self::get_php_tuning_env_variables(), self::get_xdebug_env_variables() ),
static function ( $value ) {
Expand Down
2 changes: 1 addition & 1 deletion utils/behat-parallel.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ function wp_cli_tests_docker_worker_command( $name, $php_image, $db_image, array
}

foreach ( getenv() as $key => $value ) {
if ( preg_match( '/^(WP_VERSION|NO_COLOR|CI|GITHUB_TOKEN|WP_CLI_TEST_(DBTYPE|OBJECT_CACHE|CORE_ZIP|QUIET|LOG_RUN_TIMES|PHP_TUNING|WP_VERSION_CACHE_TTL))$/', $key ) ) {
if ( preg_match( '/^(WP_VERSION|NO_COLOR|CI|GITHUB_TOKEN|WP_CLI_TEST_(DBTYPE|OBJECT_CACHE|CORE_ZIP|QUIET|LOG_RUN_TIMES|PHP_TUNING|WP_VERSION_CACHE_TTL)|WP_CLI_TRUST_PROJECT_CONFIG)$/', $key ) ) {
$env[ $key ] = $value;
}
}
Expand Down
Loading