Fixed doctrine middlewares

We now look directly onto the driver arguments instead of retrieving a database platform, for which we would need the database version.

As we modify driver specific options there, this might be the better choice anyway
This commit is contained in:
Jan Böhmer 2024-06-09 23:28:46 +02:00
parent 43ca543651
commit 777bfed813
3 changed files with 3 additions and 3 deletions

View file

@ -42,7 +42,7 @@ class MySQLSSLConnectionMiddlewareDriver extends AbstractDriverMiddleware
public function connect(array $params): Connection
{
//Only set this on MySQL connections, as other databases don't support this parameter
if($this->enabled && $this->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
if($this->enabled && $params['driver'] === 'pdo_mysql') {
$params['driverOptions'][\PDO::MYSQL_ATTR_SSL_CA] = CaBundle::getSystemCaRootBundlePath();
$params['driverOptions'][\PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = $this->verify;
}

View file

@ -41,7 +41,7 @@ class SQLiteRegexExtensionMiddlewareDriver extends AbstractDriverMiddleware
$connection = parent::connect($params); // TODO: Change the autogenerated stub
//Then add the functions if we are on SQLite
if ($this->getDatabasePlatform() instanceof SqlitePlatform) {
if ($params['driver'] === 'pdo_sqlite') {
$native_connection = $connection->getNativeConnection();
//Ensure that the function really exists on the connection, as it is marked as experimental according to PHP documentation

View file

@ -35,7 +35,7 @@ class SetSQLModeMiddlewareDriver extends AbstractDriverMiddleware
public function connect(array $params): Connection
{
//Only set this on MySQL connections, as other databases don't support this parameter
if($this->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
if($params['driver'] === 'pdo_mysql') {
//1002 is \PDO::MYSQL_ATTR_INIT_COMMAND constant value
$params['driverOptions'][\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode, \'ONLY_FULL_GROUP_BY\', \'\'))';
}