Bug #82555

Driver switches to mysqli when using postgresql

Added by RVVN no-lastname-given almost 5 years ago. Updated almost 5 years ago.

Should have
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:



to deal more easily with 4-bytes UTF8 characters (like emojis), we've decided to switch to PostgreSQL.

Our database connection is configured as following in LocalConfiguration.php :

'DB' => [
        'Connections' => [
            'Default' => [
                'charset' => 'utf8',
                'dbname' => 'xxxx',
                //'driver' => 'mysqli',
                'driver' => 'pdo_pgsql',
                'host' => 'xxxx',
                'password' => 'xxxx',
                //'port' => 3306,
                'port' => 5432,
                'user' => 'xxxx',

We can log in and display content in backend.

But as we try to save a content element, or even listing extensions, an exception occurs and we can see that the DB driver is switching to mysqli. Here is a (simplified) trace when we try to access to extension manager :

typo3/sysext/core/Classes/Database/DatabaseConnection.php: $tables_result = $this->query('SHOW TABLE STATUS FROM `' . $this->databaseName . '`');

typo3/sysext/core/Classes/Database/DatabaseConnection.php: $this->connectDB();

typo3/sysext/core/Classes/Database/DatabaseConnection.php: $this->sql_pconnect();

vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php: $this->connect();

vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php: $this->_conn = $this->_driver->connect($this->_params, $user, $password, $driverOptions);

vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php: throw DBALException::driverException($this, $e);

Final result : Doctrine\DBAL\Driver\AbstractMySQLDriver::convertException("An exception occured in driver: MySQL server has gone away", Doctrine\DBAL\Driver\Mysqli\MysqliException)

The sql_pconnect() function contains the following code that explicitly instantiates a connection using mysqli driver :

// We are not using the TYPO3 CMS shim here as the database parameters in this class
        // are settable externally. This requires building the connection parameter array
        // just in time when establishing the connection.
        $connection = \Doctrine\DBAL\DriverManager::getConnection([
            'driver' => 'mysqli',
            'wrapperClass' => Connection::class,
            'host' => $host,
            'port' => (int)$this->databasePort,
            'unix_socket' => $this->databaseSocket,
            'user' => $this->databaseUsername,
            'password' => $this->databaseUserPassword,
            'charset' => $this->connectionCharset,

        // Mimic the previous behavior of returning false on connection errors
        try {
            /** @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection $mysqliConnection */
            $mysqliConnection = $connection->getWrappedConnection();
            $this->link = $mysqliConnection->getWrappedResourceHandle();
        } catch (\Doctrine\DBAL\Exception\ConnectionException $exception) {
            return false;

Why is that hard coded?

Did we miss something in our PostgreSQL configuration ?


Updated by Morton Jonuschat almost 5 years ago

  • Status changed from New to Needs Feedback

From the incomplete stacktrace it seems that something in your installation is using the legacy DatabaseConnection class which is MySQL only. Can you provide a full stacktrace and a summary of steps needed to trigger the error?


Updated by RVVN no-lastname-given almost 5 years ago

You're right, seems to be related to RealURL extension :


/** @var \TYPO3\CMS\Core\Database\DatabaseConnection */
        protected $databaseConnection;
$this->databaseConnection = $GLOBALS['TYPO3_DB'];
$tables = $this->databaseConnection->admin_get_tables();

Sorry for not having fully read the stacktrace :/

Is that a legacy class call ?


Updated by Morton Jonuschat almost 5 years ago

  • Category deleted (Database API (Doctrine DBAL))
  • Status changed from Needs Feedback to Rejected

Yes, that’s a call to the legacy API ($GLOBALS['TYPO3_DB']), you might want to check if an update (or fork) of RealURL exists which uses the new Database classes to support PostgreSQL.

Also available in: Atom PDF