phacility/phabricator · error · Exception

About to call %s, but the PHP MySQL extension is not availab

Error message

About to call %s, but the PHP MySQL extension is not available!

What it means

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.

Source

Thrown at src/infrastructure/storage/connection/mysql/AphrontMySQLDatabaseConnection.php:33

  public function getInsertID() {
    return mysql_insert_id($this->requireConnection());
  }

  public function getAffectedRows() {
    return mysql_affected_rows($this->requireConnection());
  }

  protected function closeConnection() {
    mysql_close($this->requireConnection());
  }

  protected function connect() {
    if (!function_exists('mysql_connect')) {
      // We have to '@' the actual call since it can spew all sorts of silly
      // noise, but it will also silence fatals caused by not having MySQL
      // installed, which has bitten me on three separate occasions. Make sure
      // such failures are explicit and loud.
      throw new Exception(
        pht(
          'About to call %s, but the PHP MySQL extension is not available!',
          'mysql_connect()'));
    }

    $user = $this->getConfiguration('user');
    $host = $this->getConfiguration('host');
    $port = $this->getConfiguration('port');

    if ($port) {
      $host .= ':'.$port;
    }

    $database = $this->getConfiguration('database');

    $pass = $this->getConfiguration('pass');
    if ($pass instanceof PhutilOpaqueEnvelope) {
      $pass = $pass->openEnvelope();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Use AphrontMySQLiDatabaseConnection (the modern, default driver) instead of the ext-mysql class
  2. Remove any custom configuration or code path that selects AphrontMySQLDatabaseConnection
  3. 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
  4. Verify with php -m that mysqli is present for the replacement driver

Example fix

// before: legacy ext-mysql driver, removed in PHP 7
$conn = new AphrontMySQLDatabaseConnection();

// after: mysqli driver
$conn = new AphrontMySQLiDatabaseConnection();
Defensive patterns

Strategy: validation

Validate before calling

// When constructing a connection, prefer mysqli; only fall back to the
// legacy driver when the runtime actually provides it:
if (class_exists('mysqli', false)) {
  $conn = new AphrontMySQLiDatabaseConnection();
} else if (function_exists('mysql_connect')) {
  $conn = new AphrontMySQLDatabaseConnection(); // PHP 5.x only
} else {
  throw new Exception('No usable PHP MySQL extension is loaded.');
}

Prevention

When it happens

Trigger: 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.

Common situations: OS/PHP upgrades removing ext/mysql; forks or old documentation referencing the mysql_* driver; new installs accidentally choosing the wrong connection class.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/c5155d9aa3d8bc6c. Report an issue: GitHub.