Skip to content

Commit

Permalink
Added fix to ensure escaped backslash paths are preserved in DB_DATAB…
Browse files Browse the repository at this point in the history
…ASE env values (#1266)

Co-authored-by: Luke Towers <[email protected]>

Related #1242
  • Loading branch information
jaxwilko authored Dec 4, 2024
1 parent 4a31245 commit b5ccea7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/system/console/WinterEnv.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ protected function updateEnvFile(): void
$dbConfig = $this->dbConfig()[$default] ?? [];

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

Expand Down

0 comments on commit b5ccea7

Please sign in to comment.