mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(PDO): Switch away from deprecated PDO parts
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
121973d336
commit
6bc73b0dab
2 changed files with 22 additions and 7 deletions
|
|
@ -88,12 +88,23 @@ class ConnectionFactory {
|
|||
throw new \InvalidArgumentException("Unsupported type: $type");
|
||||
}
|
||||
$result = $this->defaultConnectionParams[$normalizedType];
|
||||
// \PDO::MYSQL_ATTR_FOUND_ROWS may not be defined, e.g. when the MySQL
|
||||
// driver is missing. In this case, we won't be able to connect anyway.
|
||||
if ($normalizedType === 'mysql' && defined('\PDO::MYSQL_ATTR_FOUND_ROWS')) {
|
||||
$result['driverOptions'] = [
|
||||
\PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
];
|
||||
/**
|
||||
* {@see \PDO::MYSQL_ATTR_FOUND_ROWS} may not be defined, e.g. when the MySQL
|
||||
* driver is missing. In this case, we won't be able to connect anyway.
|
||||
* In PHP 8.5 it's deprecated and {@see \Pdo\Mysql::ATTR_FOUND_ROWS} should be used,
|
||||
* but that is only available since PHP 8.4
|
||||
*/
|
||||
if ($normalizedType === 'mysql') {
|
||||
if (PHP_VERSION_ID >= 80500 && class_exists(\Pdo\Mysql::class)) {
|
||||
/** @psalm-suppress UndefinedClass */
|
||||
$result['driverOptions'] = [
|
||||
\Pdo\Mysql::ATTR_FOUND_ROWS => true,
|
||||
];
|
||||
} elseif (PHP_VERSION_ID < 80500 && defined('\PDO::MYSQL_ATTR_FOUND_ROWS')) {
|
||||
$result['driverOptions'] = [
|
||||
\PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,11 @@ class SQLiteSessionInit implements EventSubscriber {
|
|||
/** @var \Doctrine\DBAL\Driver\PDO\Connection $connection */
|
||||
$connection = $args->getConnection()->getWrappedConnection();
|
||||
$pdo = $connection->getWrappedConnection();
|
||||
$pdo->sqliteCreateFunction('md5', 'md5', 1);
|
||||
if (PHP_VERSION_ID >= 80500 && method_exists($pdo, 'createFunction')) {
|
||||
$pdo->createFunction('md5', 'md5', 1);
|
||||
} else {
|
||||
$pdo->sqliteCreateFunction('md5', 'md5', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSubscribedEvents() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue