Skip to content

Commit 304ff7e

Browse files
mondrakeenzolutions
authored andcommitted
Use Database::getConnectionInfoAsUrl to get the db URL (#4046)
1 parent 72bd831 commit 304ff7e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Command/Site/StatusCommand.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,26 +176,22 @@ protected function getSystemData()
176176
protected function getConnectionData()
177177
{
178178
$connectionInfo = Database::getConnectionInfo();
179+
$has_password = FALSE;
179180

180181
$connectionData = [];
181182
foreach ($this->connectionInfoKeys as $connectionInfoKey) {
182183
if ('password' == $connectionInfoKey) {
184+
$has_password = TRUE;
183185
continue;
184186
}
185187

186188
$connectionKey = $this->trans('commands.site.status.messages.' . $connectionInfoKey);
187189
$connectionData['database'][$connectionKey] = $connectionInfo['default'][$connectionInfoKey];
188190
}
189191

190-
$connectionData['database'][$this->trans('commands.site.status.messages.connection')] = sprintf(
191-
'%s//%s:%s@%s%s/%s',
192-
$connectionInfo['default']['driver'],
193-
$connectionInfo['default']['username'],
194-
$connectionInfo['default']['password'],
195-
$connectionInfo['default']['host'],
196-
$connectionInfo['default']['port'] ? ':' . $connectionInfo['default']['port'] : '',
197-
$connectionInfo['default']['database']
198-
);
192+
$connection_url = Database::getConnectionInfoAsUrl();
193+
$displayable_url = $has_password ? preg_replace('/(?<=:)([^@:]+)(?=@[^@]+$)/', '********', $connection_url, 1) : $connection_url;
194+
$connectionData['database'][$this->trans('commands.site.status.messages.connection')] = $displayable_url;
199195

200196
return $connectionData;
201197
}

0 commit comments

Comments
 (0)