Skip to content

Commit d6a74bd

Browse files
committed
fix: read XDK root from config files to prevent env var contamination
xdebug_setup_env_vars() sets the XDK env var to the full stack-specific key (e.g. "slic_a1dc6067") during bootstrap. When a second stack is registered, slic_stacks_xdebug_server_name() read that contaminated value via getenv('XDK') and appended another hash, producing incorrect keys like "slic_a1dc6067_ac80b3a1" instead of "slic_ac80b3a1".
1 parent 465dd41 commit d6a74bd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/stacks.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,15 @@ function slic_stacks_xdebug_server_name($stack_id) {
583583
// Use the same hash approach as project names for consistency
584584
$hash = substr(md5($stack_id), 0, 8);
585585

586-
// Build the key from the root defined in the config file, if any.
587-
$key_root = getenv('XDK') ?: 'slic';
586+
// Read XDK root from config files, not from getenv() which may be
587+
// overwritten by xdebug_setup_env_vars() with a full stack-specific key
588+
// (e.g. "slic_a1dc6067") instead of just the root "slic".
589+
$root = dirname(__DIR__);
590+
$config = read_env_file($root . '/.env.slic');
591+
if (file_exists($root . '/.env.slic.local')) {
592+
$config = array_merge($config, read_env_file($root . '/.env.slic.local'));
593+
}
594+
$key_root = $config['XDK'] ?? 'slic';
588595

589596
return $key_root . '_' . $hash;
590597
}

0 commit comments

Comments
 (0)