Skip to content

Commit b5ccea7

Browse files
authored
Added fix to ensure escaped backslash paths are preserved in DB_DATABASE env values (#1266)
Co-authored-by: Luke Towers <[email protected]> Related #1242
1 parent 4a31245 commit b5ccea7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/system/console/WinterEnv.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ protected function updateEnvFile(): void
122122
$dbConfig = $this->dbConfig()[$default] ?? [];
123123

124124
foreach ($dbConfig as $dbEnvKey => $dbConfigKey) {
125-
$env->set($dbEnvKey, config(join('.', [$config, 'connections', $default, $dbConfigKey])));
125+
$value = config(join('.', [$config, 'connections', $default, $dbConfigKey]));
126+
// Fix for https://github.com/wintercms/winter/issues/1242#issuecomment-2515344385
127+
if ($dbEnvKey === 'DB_DATABASE' && PHP_OS_FAMILY === 'Windows' && str_contains($value, '\\')) {
128+
$value = str_replace('\\', '\\\\', $value);
129+
}
130+
$env->set($dbEnvKey, $value);
126131
}
127132
}
128133

0 commit comments

Comments
 (0)