Skip to content

Commit 5446612

Browse files
swissspidyCopilot
andauthored
Update src/Context/FeatureContext.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7618a3a commit 5446612

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

src/Context/FeatureContext.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,32 @@ private static function get_process_env_variables(): array {
471471
}
472472

473473
if ( self::running_with_xdebug() ) {
474-
$env['XDEBUG_MODE'] = 'debug';
475-
$env['XDEBUG_SESSION'] = '1';
476-
$env['XDEBUG_CONFIG'] = 'idekey=WP_CLI_TEST_XDEBUG log_level=0';
474+
$xdebug_mode = getenv( 'XDEBUG_MODE' );
475+
if ( false !== $xdebug_mode && '' !== $xdebug_mode ) {
476+
$modes = array_filter(
477+
array_map(
478+
'trim',
479+
explode( ',', $xdebug_mode )
480+
),
481+
static function ( $mode ) {
482+
return '' !== $mode;
483+
}
484+
);
485+
if ( ! in_array( 'debug', $modes, true ) ) {
486+
$modes[] = 'debug';
487+
}
488+
$env['XDEBUG_MODE'] = implode( ',', $modes );
489+
} else {
490+
$env['XDEBUG_MODE'] = 'debug';
491+
}
492+
493+
if ( false === getenv( 'XDEBUG_SESSION' ) ) {
494+
$env['XDEBUG_SESSION'] = '1';
495+
}
496+
497+
if ( false === getenv( 'XDEBUG_CONFIG' ) ) {
498+
$env['XDEBUG_CONFIG'] = 'idekey=WP_CLI_TEST_XDEBUG log_level=0';
499+
}
477500
}
478501

479502
$config_path = getenv( 'WP_CLI_CONFIG_PATH' );

0 commit comments

Comments
 (0)