From 0abe8be14e87db4598634f2d05bacac2095baee1 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 12:52:06 +0100 Subject: [PATCH] Support nested variables in `INVOKE_WP_CLI_WITH_PHP_ARGS` --- features/steps.feature | 6 ++++++ src/Context/FeatureContext.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/features/steps.feature b/features/steps.feature index 6968ba636..7ee03d39e 100644 --- a/features/steps.feature +++ b/features/steps.feature @@ -68,6 +68,12 @@ Feature: Make sure "Given", "When", "Then" steps work as expected Then STDOUT should match /\d\.\d/ And STDERR should be empty + Scenario: Nested special variables + Given an empty directory + When I run `echo {INVOKE_WP_CLI_WITH_PHP_ARGS--dopen_basedir={RUN_DIR}} cli info` + Then STDOUT should match /^WP_CLI_PHP_ARGS=-dopen_basedir=.* ?wp cli info/ + And STDERR should be empty + @require-mysql-or-mariadb Scenario: SQL related variables When I run `echo {MYSQL_BINARY}` diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index c39620fff..65d29c386 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -980,7 +980,7 @@ private function replace_invoke_wp_cli_with_php_args( $str ) { } $str = preg_replace_callback( - '/{INVOKE_WP_CLI_WITH_PHP_ARGS-([^}]*)}/', + '/{INVOKE_WP_CLI_WITH_PHP_ARGS-(.*)}/', static function ( $matches ) use ( $phar_path, $shell_path ) { return $phar_path ? "php {$matches[1]} {$phar_path}" : ( 'WP_CLI_PHP_ARGS=' . escapeshellarg( $matches[1] ) . ' ' . $shell_path ); },