Skip to content
Permalink
Browse files

Use Database::getConnectionInfoAsUrl to get the db URL (#4046)

  • Loading branch information...
mondrake authored and enzolutions committed May 20, 2019
1 parent 72bd831 commit 304ff7e17668e1b01cda40bb4f77aacf0c18e6e7
Showing with 5 additions and 9 deletions.
  1. +5 −9 src/Command/Site/StatusCommand.php
@@ -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;
}

0 comments on commit 304ff7e

Please sign in to comment.
You can’t perform that action at this time.