Skip to content

Commit 39e8f38

Browse files
pookmishvishalkhode1
authored andcommitted
ISSUE-69: Respect config.yml database credentials if set.
1 parent 5c010ff commit 39e8f38

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/Drush/Commands/SettingsDrushCommands.php

+11-12
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,18 @@ class SettingsDrushCommands extends BaseDrushCommands {
4747
description: 'Generates the settings.php for site2 passing db credentials.',
4848
)]
4949
public function initSettings(array $options = [
50-
'database' => 'drupal',
51-
'username' => 'drupal',
52-
'password' => 'drupal',
53-
'host' => 'localhost',
54-
'port' => "3306",
50+
'database' => NULL,
51+
'username' => NULL,
52+
'password' => NULL,
53+
'host' => NULL,
54+
'port' => NULL,
5555
]): int {
56-
$db["drupal"]["db"] = [
57-
'database' => $options['database'],
58-
'username' => $options['username'],
59-
'password' => $options['password'],
60-
'host' => $options['host'],
61-
'port' => $options['port'],
62-
];
56+
$db = [];
57+
$db['drupal']['db'] = array_filter(
58+
$options,
59+
fn($value, $key) => in_array($key, ['database', 'username', 'password', 'host', 'port']) && $value !== NULL,
60+
ARRAY_FILTER_USE_BOTH
61+
);
6362
try {
6463
$site_directory = $this->getSitesSubdirFromUri($this->getConfigValue("docroot"), $this->getConfigValue("drush.uri"));
6564
$settings = new Settings($this->getConfigValue("docroot"), $site_directory);

0 commit comments

Comments
 (0)