Skip to content

Commit f64671e

Browse files
Fix Doctrine deprecations
1 parent 3c59f97 commit f64671e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ public function updateTimestamp($sessionId, $data)
397397
$updateStmt = $this->pdo->prepare(
398398
"UPDATE $this->table SET $this->lifetimeCol = :expiry, $this->timeCol = :time WHERE $this->idCol = :id"
399399
);
400-
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
401-
$updateStmt->bindParam(':expiry', $expiry, \PDO::PARAM_INT);
400+
$updateStmt->bindValue(':id', $sessionId, \PDO::PARAM_STR);
401+
$updateStmt->bindValue(':expiry', $expiry, \PDO::PARAM_INT);
402402
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
403403
$updateStmt->execute();
404404
} catch (\PDOException $e) {

Session/Storage/Handler/SessionHandlerFactory.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
1313

14+
use Doctrine\DBAL\Configuration;
1415
use Doctrine\DBAL\DriverManager;
16+
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
17+
use Doctrine\DBAL\Tools\DsnParser;
18+
use Doctrine\ORM\ORMSetup;
1519
use Symfony\Component\Cache\Adapter\AbstractAdapter;
1620
use Symfony\Component\Cache\Traits\RedisClusterProxy;
1721
use Symfony\Component\Cache\Traits\RedisProxy;
@@ -71,7 +75,15 @@ public static function createHandler($connection): AbstractSessionHandler
7175
if (!class_exists(DriverManager::class)) {
7276
throw new \InvalidArgumentException(sprintf('Unsupported DSN "%s". Try running "composer require doctrine/dbal".', $connection));
7377
}
74-
$connection = DriverManager::getConnection(['url' => $connection])->getWrappedConnection();
78+
$connection[3] = '-';
79+
$params = class_exists(DsnParser::class) ? (new DsnParser())->parse($connection) : ['url' => $connection];
80+
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
81+
if (class_exists(DefaultSchemaManagerFactory::class)) {
82+
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
83+
}
84+
85+
$connection = DriverManager::getConnection($params, $config);
86+
$connection = method_exists($connection, 'getNativeConnection') ? $connection->getNativeConnection() : $connection->getWrappedConnection();
7587
// no break;
7688

7789
case str_starts_with($connection, 'mssql://'):

0 commit comments

Comments
 (0)