Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 72cd43a

Browse filesBrowse files
committed
bug #43281 [Lock] Use platform to identify the PDO driver (Jean85)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Lock] Use platform to identify the PDO driver | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #43048 | License | MIT This should fix the issue in the same way we did for #42011. I'm not sure if I should add/change any test... Commits ------- 687a7ed [Lock] Use platform to identify the PDO driver
2 parents 26a72ff + 687a7ed commit 72cd43a
Copy full SHA for 72cd43a

File tree

1 file changed

+15
-15
lines changed
Filter options

1 file changed

+15
-15
lines changed

‎src/Symfony/Component/Lock/Store/PdoStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/PdoStore.php
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ public function createTable(): void
299299
$sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $this->tokenCol VARCHAR(64) NOT NULL, $this->expirationCol INTEGER)";
300300
break;
301301
default:
302-
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for PDO driver "%s".', $driver));
302+
throw new \DomainException(sprintf('Creating the lock table is currently not implemented for platform "%s".', $driver));
303303
}
304304

305305
if (method_exists($conn, 'executeStatement')) {
@@ -351,33 +351,33 @@ private function getDriver(): string
351351
$this->driver = $con->getAttribute(\PDO::ATTR_DRIVER_NAME);
352352
} else {
353353
$driver = $con->getDriver();
354+
$platform = $driver->getDatabasePlatform();
355+
356+
if ($driver instanceof \Doctrine\DBAL\Driver\Mysqli\Driver) {
357+
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
358+
}
354359

355360
switch (true) {
356-
case $driver instanceof \Doctrine\DBAL\Driver\Mysqli\Driver:
357-
throw new \LogicException(sprintf('The adapter "%s" does not support the mysqli driver, use pdo_mysql instead.', static::class));
358-
case $driver instanceof \Doctrine\DBAL\Driver\AbstractMySQLDriver:
361+
case $platform instanceof \Doctrine\DBAL\Platforms\MySQLPlatform:
362+
case $platform instanceof \Doctrine\DBAL\Platforms\MySQL57Platform:
359363
$this->driver = 'mysql';
360364
break;
361-
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver:
362-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLite\Driver:
365+
case $platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform:
363366
$this->driver = 'sqlite';
364367
break;
365-
case $driver instanceof \Doctrine\DBAL\Driver\PDOPgSql\Driver:
366-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\PgSQL\Driver:
368+
case $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform:
369+
case $platform instanceof \Doctrine\DBAL\Platforms\PostgreSQL94Platform:
367370
$this->driver = 'pgsql';
368371
break;
369-
case $driver instanceof \Doctrine\DBAL\Driver\OCI8\Driver:
370-
case $driver instanceof \Doctrine\DBAL\Driver\PDOOracle\Driver:
371-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\OCI\Driver:
372+
case $platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform:
372373
$this->driver = 'oci';
373374
break;
374-
case $driver instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver:
375-
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver:
376-
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver:
375+
case $platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform:
376+
case $platform instanceof \Doctrine\DBAL\Platforms\SQLServer2012Platform:
377377
$this->driver = 'sqlsrv';
378378
break;
379379
default:
380-
$this->driver = \get_class($driver);
380+
$this->driver = \get_class($platform);
381381
break;
382382
}
383383
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.