public function connect($mode, $server = null)
{
list($user, $password, $server) = $this->getConnectionParams($mode, $server);
if (is_null($user) || is_null($password)) {
trigger_error(__('Missing connection parameters!'), E_USER_WARNING);
return false;
}
// Do not show location and backtrace for connection errors
$GLOBALS['error_handler']->setHideLocation(true);
$result = $this->_extension->connect($user, $password, $server);
$GLOBALS['error_handler']->setHideLocation(false);
if ($result) {
/* Run post connect for user connections */
if ($mode == DatabaseInterface::CONNECT_USER) {
$this->postConnect($result);
}
return $result;
}
if ($mode == DatabaseInterface::CONNECT_CONTROL) {
trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING);
return false;
} else {
if ($mode == DatabaseInterface::CONNECT_AUXILIARY) {
// Do not go back to main login if connection failed
// (currently used only in unit testing)
return false;
}
}
Logging::logUser($user, 'mysql-denied');
$GLOBALS['auth_plugin']->authFails();
return $result;
}