{"record":{"id":"c5155d9aa3d8bc6c","repo":"phacility/phabricator","slug":"about-to-call-s-but-the-php-mysql-extension-is-n","errorCode":null,"errorMessage":"About to call %s, but the PHP MySQL extension is not available!","messagePattern":"About to call (.+?), but the PHP MySQL extension is not available!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php","lineNumber":33,"sourceCode":"  public function getInsertID() {\n    return mysql_insert_id($this->requireConnection());\n  }\n\n  public function getAffectedRows() {\n    return mysql_affected_rows($this->requireConnection());\n  }\n\n  protected function closeConnection() {\n    mysql_close($this->requireConnection());\n  }\n\n  protected function connect() {\n    if (!function_exists('mysql_connect')) {\n      // We have to '@' the actual call since it can spew all sorts of silly\n      // noise, but it will also silence fatals caused by not having MySQL\n      // installed, which has bitten me on three separate occasions. Make sure\n      // such failures are explicit and loud.\n      throw new Exception(\n        pht(\n          'About to call %s, but the PHP MySQL extension is not available!',\n          'mysql_connect()'));\n    }\n\n    $user = $this->getConfiguration('user');\n    $host = $this->getConfiguration('host');\n    $port = $this->getConfiguration('port');\n\n    if ($port) {\n      $host .= ':'.$port;\n    }\n\n    $database = $this->getConfiguration('database');\n\n    $pass = $this->getConfiguration('pass');\n    if ($pass instanceof PhutilOpaqueEnvelope) {\n      $pass = $pass->openEnvelope();","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php#L15-L51","documentation":"The legacy AphrontMySQLDatabaseConnection (ext-mysql driver) checks for mysql_connect() before calling it, because a missing extension would otherwise produce a confusing suppressed fatal. ext/mysql was deprecated in PHP 5.5 and removed entirely in PHP 7.0, so on any modern PHP this construction always throws. The maintained driver is the mysqli one.","triggerScenarios":"Instantiating or configuring AphrontMySQLDatabaseConnection on PHP 7+; old configuration or custom code that explicitly selects the ext-mysql class; upgrading a host from PHP 5.x to 7.x while the legacy driver stayed selected.","commonSituations":"OS/PHP upgrades removing ext/mysql; forks or old documentation referencing the mysql_* driver; new installs accidentally choosing the wrong connection class.","solutions":["Use AphrontMySQLiDatabaseConnection (the modern, default driver) instead of the ext-mysql class","Remove any custom configuration or code path that selects AphrontMySQLDatabaseConnection","Only if you must stay on the legacy driver: run PHP 5.x with ext/mysql compiled in — this is not viable on PHP 7 or later","Verify with php -m that mysqli is present for the replacement driver"],"exampleFix":"// before: legacy ext-mysql driver, removed in PHP 7\n$conn = new AphrontMySQLDatabaseConnection();\n\n// after: mysqli driver\n$conn = new AphrontMySQLiDatabaseConnection();","handlingStrategy":"validation","validationCode":"// When constructing a connection, prefer mysqli; only fall back to the\n// legacy driver when the runtime actually provides it:\nif (class_exists('mysqli', false)) {\n  $conn = new AphrontMySQLiDatabaseConnection();\n} else if (function_exists('mysql_connect')) {\n  $conn = new AphrontMySQLDatabaseConnection(); // PHP 5.x only\n} else {\n  throw new Exception('No usable PHP MySQL extension is loaded.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to AphrontMySQLiDatabaseConnection; the ext-mysql driver is dead on PHP 7+","Sweep configuration and custom code for references to AphrontMySQLDatabaseConnection before PHP upgrades","Verify the runtime with php -m (mysqlnd/mysqli) as part of environment provisioning"],"tags":["php","extension","ext-mysql","driver","php7","runtime-environment"],"backgroundTag":"missing-php-extension","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}