in Synchronize, the connection problems detection no longer worked

This commit is contained in:
Marc Delisle
2009-10-16 00:32:42 +00:00
parent 593c28aabd
commit 9ae329e4ad
3 changed files with 45 additions and 29 deletions

View File

@@ -46,9 +46,10 @@ function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persist
* @param string $password mysql user password
* @param boolean $is_controluser
* @param array $server host/port/socket/persistant
* @param boolean $auxiliary_connection (if fails, don't go back to login)
* @return mixed false on error or a mysqli object on success
*/
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null)
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false)
{
global $cfg, $php_errormsg;
@@ -100,22 +101,30 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu
$link = PMA_DBI_real_connect($cfg['Server']['host'] . $server_port . $server_socket, $user, '', empty($client_flags) ? NULL : $client_flags);
}
} else {
if (!isset($server['host']))
if (!isset($server['host'])) {
$link = PMA_DBI_real_connect($server_socket, $user, $password, NULL, $server_persistant);
else
} else {
$link = PMA_DBI_real_connect($server['host'] . $server_port . $server_socket, $user, $password, NULL, $server_persistant);
}
}
if (empty($link)) {
if ($is_controluser) {
trigger_error($GLOBALS['strControluserFailed'], E_USER_WARNING);
return false;
}
// we could be calling PMA_DBI_connect() to connect to another
// server, for example in the Synchronize feature, so do not
// go back to main login if it fails
if (! $auxiliary_connection) {
PMA_log_user($user, 'mysql-denied');
PMA_auth_fails();
} else {
return false;
}
} // end if
if (!$server)
if (! $server) {
PMA_DBI_postConnect($link, $is_controluser);
}
return $link;
}

View File

@@ -55,9 +55,10 @@ if (! defined('MYSQLI_TYPE_BIT')) {
* @param string $password mysql user password
* @param boolean $is_controluser
* @param array $server host/port/socket
* @param boolean $auxiliary_connection (if fails, don't go back to login)
* @return mixed false on error or a mysqli object on success
*/
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null)
function PMA_DBI_connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false)
{
if ($server) {
$server_port = (empty($server['port']))
@@ -85,7 +86,6 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu
// NULL enables connection to the default socket
$link = mysqli_init();
mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true);
@@ -118,11 +118,18 @@ function PMA_DBI_connect($user, $password, $is_controluser = false, $server = nu
trigger_error($GLOBALS['strControluserFailed'], E_USER_WARNING);
return false;
}
// we could be calling PMA_DBI_connect() to connect to another
// server, for example in the Synchronize feature, so do not
// go back to main login if it fails
if (! $auxiliary_connection) {
PMA_log_user($user, 'mysql-denied');
PMA_auth_fails();
} // end if
} else {
return false;
}
} else {
PMA_DBI_postConnect($link, $is_controluser);
}
return $link;
}

View File

@@ -80,20 +80,20 @@ if ((isset($_REQUEST['submit_connect']))) {
}
}
${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"});
${"{$con}_connection"} = PMA_DBI_connect(${"{$con}_username"}, ${"{$con}_password"}, $is_controluser = false, ${"{$con}_server"}, $auxiliary_connection = true);
} // end foreach ($cons as $con)
if ((! $src_connection && $src_type=='rmt') || (! $trg_connection && $trg_type=='rmt')) {
if ((! $src_connection && $src_type == 'rmt') || (! $trg_connection && $trg_type == 'rmt')) {
/**
* Displays the connection error string if
* connections are not established
*/
echo '<div class="error">' . "\n" ;
if(! $src_connection) {
if(! $src_connection && $src_type == 'rmt') {
echo $GLOBALS['strCouldNotConnectSource'].'<br />';
}
if(! $trg_connection){
if(! $trg_connection && $trg_type == 'rmt'){
echo $GLOBALS['strCouldNotConnectTarget'];
}
echo '</div>';