Differential D15669 Diff 37771 src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/storage/connection/mysql/AphrontMySQLDatabaseConnection.php
| Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | protected function connect() { | ||||
| $database = $this->getConfiguration('database'); | $database = $this->getConfiguration('database'); | ||||
| $pass = $this->getConfiguration('pass'); | $pass = $this->getConfiguration('pass'); | ||||
| if ($pass instanceof PhutilOpaqueEnvelope) { | if ($pass instanceof PhutilOpaqueEnvelope) { | ||||
| $pass = $pass->openEnvelope(); | $pass = $pass->openEnvelope(); | ||||
| } | } | ||||
| $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( | $conn = @mysql_connect( | ||||
| $host, | $host, | ||||
| $user, | $user, | ||||
| $pass, | $pass, | ||||
| $new_link = true, | $new_link = true, | ||||
| $flags = 0); | $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) { | if (!$conn) { | ||||
| $errno = mysql_errno(); | $errno = mysql_errno(); | ||||
| $error = mysql_error(); | $error = mysql_error(); | ||||
| $this->throwConnectionException($errno, $error, $user, $host); | $this->throwConnectionException($errno, $error, $user, $host); | ||||
| } | } | ||||
| if ($database !== null) { | if ($database !== null) { | ||||
| ▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines | |||||