File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ' );
You can’t perform that action at this time.
0 commit comments