From cfbc31bfa62ea3841f766146adc06fecdfd38f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 18 Apr 2016 13:27:37 +0200 Subject: [PATCH] Better reporting of connection errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ř --- libraries/DatabaseInterface.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index 87ab7eb181..c9183d1cdc 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -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);