Skip to content

Commit

Permalink
Use Database::getConnectionInfoAsUrl to get the db URL (#4046)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondrake authored and enzolutions committed May 20, 2019
1 parent 72bd831 commit 304ff7e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Command/Site/StatusCommand.php
Expand Up @@ -176,26 +176,22 @@ protected function getSystemData()
protected function getConnectionData()
{
$connectionInfo = Database::getConnectionInfo();
$has_password = FALSE;

$connectionData = [];
foreach ($this->connectionInfoKeys as $connectionInfoKey) {
if ('password' == $connectionInfoKey) {
$has_password = TRUE;
continue;
}

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

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

return $connectionData;
}
Expand Down

0 comments on commit 304ff7e

Please sign in to comment.