diff --git a/apps/settings/lib/SetupChecks/MysqlRowFormat.php b/apps/settings/lib/SetupChecks/MysqlRowFormat.php
index 3c27b73db89..d1906a7860b 100644
--- a/apps/settings/lib/SetupChecks/MysqlRowFormat.php
+++ b/apps/settings/lib/SetupChecks/MysqlRowFormat.php
@@ -8,9 +8,9 @@ declare(strict_types=1);
*/
namespace OCA\Settings\SetupChecks;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
use OC\DB\Connection;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\SetupCheck\ISetupCheck;
@@ -34,7 +34,8 @@ class MysqlRowFormat implements ISetupCheck {
}
public function run(): SetupResult {
- if (!$this->connection->getDatabasePlatform() instanceof MySQLPlatform) {
+ if (!$this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL
+ && !$this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MARIADB) {
return SetupResult::success($this->l10n->t('You are not using MySQL'));
}
diff --git a/apps/settings/lib/SetupChecks/SupportedDatabase.php b/apps/settings/lib/SetupChecks/SupportedDatabase.php
index d083958d16e..1460bbbb901 100644
--- a/apps/settings/lib/SetupChecks/SupportedDatabase.php
+++ b/apps/settings/lib/SetupChecks/SupportedDatabase.php
@@ -8,10 +8,6 @@ declare(strict_types=1);
*/
namespace OCA\Settings\SetupChecks;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
-use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -43,9 +39,8 @@ class SupportedDatabase implements ISetupCheck {
}
public function run(): SetupResult {
- $version = null;
- $databasePlatform = $this->connection->getDatabasePlatform();
- if ($databasePlatform instanceof MySQLPlatform) {
+ $databasePlatform = $this->connection->getDatabaseProvider();
+ if ($databasePlatform === IDBConnection::PLATFORM_MYSQL || $databasePlatform === IDBConnection::PLATFORM_MARIADB) {
$statement = $this->connection->prepare("SHOW VARIABLES LIKE 'version';");
$result = $statement->execute();
$row = $result->fetch();
@@ -91,7 +86,7 @@ class SupportedDatabase implements ISetupCheck {
);
}
}
- } elseif ($databasePlatform instanceof PostgreSQLPlatform) {
+ } elseif ($databasePlatform === IDBConnection::PLATFORM_POSTGRES) {
$statement = $this->connection->prepare('SHOW server_version;');
$result = $statement->execute();
$row = $result->fetch();
@@ -111,9 +106,9 @@ class SupportedDatabase implements ISetupCheck {
])
);
}
- } elseif ($databasePlatform instanceof OraclePlatform) {
+ } elseif ($databasePlatform === IDBConnection::PLATFORM_ORACLE) {
$version = 'Oracle';
- } elseif ($databasePlatform instanceof SqlitePlatform) {
+ } elseif ($databasePlatform === IDBConnection::PLATFORM_SQLITE) {
return SetupResult::warning(
$this->l10n->t('SQLite is currently being used as the backend database. For larger installations we recommend that you switch to a different database backend. This is particularly recommended when using the desktop client for file synchronisation. To migrate to another database use the command line tool: "occ db:convert-type".'),
$this->urlGenerator->linkToDocs('admin-db-conversion')
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index f44671a2293..1b38ed03855 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -2445,11 +2445,6 @@
-
-
-
-
-
diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php
index be2826871bb..985c331570f 100644
--- a/lib/private/DB/MigrationService.php
+++ b/lib/private/DB/MigrationService.php
@@ -7,7 +7,6 @@
*/
namespace OC\DB;
-use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
@@ -578,7 +577,7 @@ class MigrationService {
throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.');
}
- if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
+ if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
// Oracle doesn't support boolean column with non-null value
if ($thing->getNotnull() && Type::lookupName($thing->getType()) === Types::BOOLEAN) {
$thing->setNotnull(false);
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index adffe09f2e8..36885d1963f 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -7,7 +7,6 @@
*/
namespace OC\User;
-use Doctrine\DBAL\Platforms\OraclePlatform;
use OC\Hooks\PublicEmitter;
use OC\Memcache\WithLocalCache;
use OCP\DB\QueryBuilder\IQueryBuilder;
@@ -16,6 +15,7 @@ use OCP\HintException;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IUser;
use OCP\IUserBackend;
@@ -564,7 +564,7 @@ class Manager extends PublicEmitter implements IUserManager {
* @since 12.0.0
*/
public function countDisabledUsers(): int {
- $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $queryBuilder = Server::get(IDBConnection::class)->getQueryBuilder();
$queryBuilder->select($queryBuilder->func()->count('*'))
->from('preferences')
->where($queryBuilder->expr()->eq('appid', $queryBuilder->createNamedParameter('core')))
@@ -592,7 +592,7 @@ class Manager extends PublicEmitter implements IUserManager {
* @since 11.0.0
*/
public function countSeenUsers() {
- $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $queryBuilder = Server::get(IDBConnection::class)->getQueryBuilder();
$queryBuilder->select($queryBuilder->func()->count('*'))
->from('preferences')
->where($queryBuilder->expr()->eq('appid', $queryBuilder->createNamedParameter('login')))
@@ -626,7 +626,7 @@ class Manager extends PublicEmitter implements IUserManager {
* @return string[] with user ids
*/
private function getSeenUserIds($limit = null, $offset = null) {
- $queryBuilder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ $queryBuilder = Server::get(IDBConnection::class)->getQueryBuilder();
$queryBuilder->select(['userid'])
->from('preferences')
->where($queryBuilder->expr()->eq(
@@ -728,7 +728,7 @@ class Manager extends PublicEmitter implements IUserManager {
// We can't load all users who already logged in
$limit = min(100, $limit ?: 25);
- $connection = \OC::$server->getDatabaseConnection();
+ $connection = Server::get(IDBConnection::class);
$queryBuilder = $connection->getQueryBuilder();
$queryBuilder->select('pref_login.userid')
->from('preferences', 'pref_login')
@@ -739,7 +739,7 @@ class Manager extends PublicEmitter implements IUserManager {
;
// Oracle don't want to run ORDER BY on CLOB column
- $loginOrder = $connection->getDatabasePlatform() instanceof OraclePlatform
+ $loginOrder = $connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE
? $queryBuilder->expr()->castColumn('pref_login.configvalue', IQueryBuilder::PARAM_INT)
: 'pref_login.configvalue';
$queryBuilder
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 3275280fc06..da92261b850 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -8,7 +8,6 @@
namespace Test\DB;
-use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
@@ -708,8 +707,8 @@ class MigrationsTest extends \Test\TestCase {
#[TestWith([true])]
#[TestWith([false])]
public function testEnsureOracleConstraintsBooleanNotNull(bool $isOracle): void {
- $this->db->method('getDatabasePlatform')
- ->willReturn($isOracle ? $this->createMock(OraclePlatform::class) : null);
+ $this->db->method('getDatabaseProvider')
+ ->willReturn($isOracle ? IDBConnection::PLATFORM_ORACLE : IDBConnection::PLATFORM_MARIADB);
$column = $this->createMock(Column::class);
$column->expects($this->any())