diff --git a/ChangeLog b/ChangeLog index acd485070..2e9319984 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,11 +7,9 @@ $Source$ 2004-06-10 Marc Delisle * libraries/auth/config.auth.lib.php, libraries/dbi/mysql.dbi.lib.php, + libraries/dbi/mysql.dbi.lib.php, lang/*: bug 968089: catch error when server is not responding and show an appropriate message - - TODO: for mysqli - * left.php: undefined variable 2004-06-09 Alexander M. Turek diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php index 447e54344..651b2fdd2 100644 --- a/libraries/auth/config.auth.lib.php +++ b/libraries/auth/config.auth.lib.php @@ -110,8 +110,10 @@ h1 {font-family: ; font-size: ' . $GLOBALS['strAccessDeniedExplanation'] . '

' . "\n"; } PMA_mysqlDie($conn_error, ''); diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 8ba49ea2e..0e97db962 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -177,18 +177,39 @@ function PMA_DBI_free_result($result) { } function PMA_DBI_getError($link = NULL) { + unset($GLOBALS['errno']); if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; - } else { - return FALSE; + // Do not stop now. We still can get the error code + // with mysqli_connect_errno() +// } else { +// return FALSE; } } - $error = mysqli_errno($link); - if ($error && PMA_MYSQL_INT_VERSION >= 40100) { - $error = '#' . ((string) $error) . ' - ' . mysqli_error($link); + + if (mysqli_connect_errno()) { + $error = mysqli_connect_errno(); + $error_message = mysqli_connect_error(); + } elseif (mysqli_errno($link)) { + $error = mysqli_errno($link); + $error_message = mysqli_error($link); + } + + // keep the error number for further check after the call to PMA_DBI_getError() + if ($error) { + $GLOBALS['errno'] = $error; + } else { + return FALSE; + } + + + if ($error && $error == 2002) { + $error = '#' . ((string) $error) . ' - ' . $GLOBALS['strServerNotResponding']; + } elseif ($error && PMA_MYSQL_INT_VERSION >= 40100) { + $error = '#' . ((string) $error) . ' - ' . $error_message; } elseif ($error) { - $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysqli_error($link)); + $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset($error_message); } return $error; }