Better reporting of connection errors

We really do not care about traceback or parameters in this case, all we
need is to display the message coming from PHP.

Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
Michal Čihař 2016-04-18 13:27:37 +02:00
parent 951f1fed5f
commit cfbc31bfa6

View File

@ -2351,10 +2351,22 @@ class DatabaseInterface
$user, $password, $is_controluser = false, $server = null,
$auxiliary_connection = false
) {
$error_count = $GLOBALS['error_handler']->countErrors();
$result = $this->_extension->connect(
$user, $password, $is_controluser, $server, $auxiliary_connection
);
/* Any errors from connection? */
if ($GLOBALS['error_handler']->countErrors() > $error_count) {
$errors = $GLOBALS['error_handler']->sliceErrors($error_count);
foreach ($errors as $error) {
trigger_error(
$error->getMessage(),
E_USER_ERROR
);
}
}
if ($result) {
if (! $auxiliary_connection && ! $is_controluser) {
$GLOBALS['dbi']->postConnect($result);