diff --git a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php --- a/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php +++ b/src/aphront/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php @@ -309,6 +309,7 @@ case 1044: // Access denied to database case 1142: // Access denied to table case 1143: // Access denied to column + case 1227: // Access denied (e.g., no SUPER for SHOW SLAVE STATUS). throw new AphrontAccessDeniedQueryException($message); case 1045: // Access denied (auth) throw new AphrontInvalidCredentialsQueryException($message); diff --git a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php --- a/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php +++ b/src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php @@ -51,12 +51,30 @@ $pass = $pass->openEnvelope(); } - $conn = @mysql_connect( - $host, - $user, - $pass, - $new_link = true, - $flags = 0); + $timeout = $this->getConfiguration('timeout'); + $timeout_ini = 'mysql.connect_timeout'; + if ($timeout) { + $old_timeout = ini_get($timeout_ini); + ini_set($timeout_ini, $timeout); + } + + try { + $conn = @mysql_connect( + $host, + $user, + $pass, + $new_link = true, + $flags = 0); + } catch (Exception $ex) { + if ($timeout) { + ini_set($timeout_ini, $old_timeout); + } + throw $ex; + } + + if ($timeout) { + ini_set($timeout_ini, $old_timeout); + } if (!$conn) { $errno = mysql_errno();