From 18e742c87271042f4cdd869cf81de7f207014fcc Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Thu, 29 Jul 2021 13:57:14 +0200 Subject: [PATCH] [TASK] Migrate more Doctrine API to be Doctrine 3.0 compatible Resolves: #94690 Releases: master Change-Id: I341b73f0c8782c75ca3c4bcf5a7038e6a86fc5dd Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70127 Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Authentication/BackendUserAuthentication.php | 4 ++-- .../Database/Query/Expression/ExpressionBuilder.php | 4 ++-- .../EventListener/SchemaColumnDefinitionListener.php | 2 +- typo3/sysext/core/Classes/Utility/RootlineUtility.php | 3 +-- .../Query/Expression/ExpressionBuilderTest.php | 10 +++++----- .../Domain/Repository/FrontendUserRepository.php | 3 +-- .../SystemEnvironment/DatabaseCheck/Platform/MySql.php | 3 +-- .../DatabaseCheck/Platform/SqlSrv.php | 4 ++-- .../Authentication/PreviewUserAuthentication.php | 2 +- 9 files changed, 16 insertions(+), 19 deletions(-) diff --git a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php index 51e15a564c2a..2616b3e6d12b 100644 --- a/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php @@ -1550,7 +1550,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email']; ) ->setMaxResults(1) ->execute() - ->fetch(\PDO::FETCH_ASSOC); + ->fetchAssociative(); $readOnlyMountPointArray = GeneralUtility::trimExplode(',', $readOnlyMountPoints); foreach ($readOnlyMountPointArray as $readOnlyMountPoint) { @@ -1977,7 +1977,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email']; ->orderBy('title') ->setMaxResults(1) ->execute() - ->fetch(\PDO::FETCH_ASSOC); + ->fetchAssociative(); } } } diff --git a/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php b/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php index 6d384c682146..545b66d3fb95 100644 --- a/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php +++ b/typo3/sysext/core/Classes/Database/Query/Expression/ExpressionBuilder.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Database\Query\Expression; -use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\TrimMode; use TYPO3\CMS\Core\Database\Connection; /** @@ -511,7 +511,7 @@ class ExpressionBuilder * @param string $char Character to be trimmed (defaults to space) * @return string */ - public function trim(string $fieldName, int $position = AbstractPlatform::TRIM_UNSPECIFIED, string $char = null) + public function trim(string $fieldName, int $position = TrimMode::UNSPECIFIED, string $char = null) { return $this->connection->getDatabasePlatform()->getTrimExpression( $this->connection->quoteIdentifier($fieldName), diff --git a/typo3/sysext/core/Classes/Database/Schema/EventListener/SchemaColumnDefinitionListener.php b/typo3/sysext/core/Classes/Database/Schema/EventListener/SchemaColumnDefinitionListener.php index c2fcfbcd3c61..f493b96d8fcc 100644 --- a/typo3/sysext/core/Classes/Database/Schema/EventListener/SchemaColumnDefinitionListener.php +++ b/typo3/sysext/core/Classes/Database/Schema/EventListener/SchemaColumnDefinitionListener.php @@ -47,7 +47,7 @@ class SchemaColumnDefinitionListener $column = $this->getEnumerationTableColumnDefinition( $tableColumn, - $event->getDatabasePlatform() + $event->getConnection()->getDatabasePlatform() ); $event->setColumn($column); diff --git a/typo3/sysext/core/Classes/Utility/RootlineUtility.php b/typo3/sysext/core/Classes/Utility/RootlineUtility.php index 5d192414abe6..ed95b81a9851 100644 --- a/typo3/sysext/core/Classes/Utility/RootlineUtility.php +++ b/typo3/sysext/core/Classes/Utility/RootlineUtility.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Core\Utility; use Doctrine\DBAL\Exception as DBALException; -use Doctrine\DBAL\FetchMode; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\Connection; @@ -529,7 +528,7 @@ class RootlineUtility ->setMaxResults(1) ->execute(); - $record = $statement->fetch(FetchMode::ASSOCIATIVE); + $record = $statement->fetchAssociative(); return $record ?: null; } diff --git a/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php b/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php index 234f22525994..2d7b9e594aa1 100644 --- a/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php +++ b/typo3/sysext/core/Tests/Unit/Database/Query/Expression/ExpressionBuilderTest.php @@ -17,7 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Expression; -use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\TrimMode; use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; use TYPO3\CMS\Core\Database\Connection; @@ -585,22 +585,22 @@ class ExpressionBuilderTest extends UnitTestCase { return [ 'trim leading character' => [ - AbstractPlatform::TRIM_LEADING, + TrimMode::LEADING, 'x', 'TRIM(LEADING "x" FROM "tableName"."fieldName")' ], 'trim trailing character' => [ - AbstractPlatform::TRIM_TRAILING, + TrimMode::TRAILING, 'x', 'TRIM(TRAILING "x" FROM "tableName"."fieldName")', ], 'trim character' => [ - AbstractPlatform::TRIM_BOTH, + TrimMode::BOTH, 'x', 'TRIM(BOTH "x" FROM "tableName"."fieldName")', ], 'trim space' => [ - AbstractPlatform::TRIM_BOTH, + TrimMode::BOTH, ' ', 'TRIM(BOTH " " FROM "tableName"."fieldName")', ] diff --git a/typo3/sysext/felogin/Classes/Domain/Repository/FrontendUserRepository.php b/typo3/sysext/felogin/Classes/Domain/Repository/FrontendUserRepository.php index 848806f46c2b..eed606621f55 100644 --- a/typo3/sysext/felogin/Classes/Domain/Repository/FrontendUserRepository.php +++ b/typo3/sysext/felogin/Classes/Domain/Repository/FrontendUserRepository.php @@ -17,7 +17,6 @@ declare(strict_types=1); namespace TYPO3\CMS\FrontendLogin\Domain\Repository; -use Doctrine\DBAL\FetchMode; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -149,7 +148,7 @@ class FrontendUserRepository ) ) ; - $result = $query->execute()->fetch(FetchMode::ASSOCIATIVE); + $result = $query->execute()->fetchAssociative(); if (!is_array($result)) { $result = []; } diff --git a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php index 32fd6e8c7f9f..d0c9fce21101 100644 --- a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php +++ b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/MySql.php @@ -188,8 +188,7 @@ class MySql extends AbstractPlatform */ protected function getIncompatibleSqlModes(Connection $connection): array { - $sqlModes = explode(',', $connection->executeQuery('SELECT @@SESSION.sql_mode;') - ->fetch(0)['@@SESSION.sql_mode']); + $sqlModes = explode(',', (string)$connection->executeQuery('SELECT @@SESSION.sql_mode;')->fetchOne()); return array_intersect($this->incompatibleSqlModes, $sqlModes); } diff --git a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/SqlSrv.php b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/SqlSrv.php index e4416245ff4b..6a23c809d7ae 100644 --- a/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/SqlSrv.php +++ b/typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck/Platform/SqlSrv.php @@ -95,7 +95,7 @@ class SqlSrv extends AbstractPlatform [$connection->getDatabase()], [\PDO::PARAM_STR] ) - ->fetch(\PDO::FETCH_NUM); + ->fetchNumeric(); foreach ($this->databaseCharsetToCheck as $databaseCharsetToCheck) { if (!stripos($defaultDatabaseCharset[0], $databaseCharsetToCheck)) { @@ -125,7 +125,7 @@ class SqlSrv extends AbstractPlatform public function checkDefaultDatabaseServerCharset(Connection $connection): void { $defaultServerCharset = $connection->executeQuery('SELECT SERVERPROPERTY(\'Collation\')') - ->fetch(\PDO::FETCH_NUM); + ->fetchNumeric(); foreach ($this->databaseServerCharsetToCheck as $databaseServerCharsetToCheck) { // is charset part of collation diff --git a/typo3/sysext/workspaces/Classes/Authentication/PreviewUserAuthentication.php b/typo3/sysext/workspaces/Classes/Authentication/PreviewUserAuthentication.php index e1c1ef7743dd..e968a7a0de16 100644 --- a/typo3/sysext/workspaces/Classes/Authentication/PreviewUserAuthentication.php +++ b/typo3/sysext/workspaces/Classes/Authentication/PreviewUserAuthentication.php @@ -77,7 +77,7 @@ class PreviewUserAuthentication extends BackendUserAuthentication ->orderBy('title') ->setMaxResults(1) ->execute() - ->fetch(\PDO::FETCH_ASSOC); + ->fetchAssociative(); } } // If the workspace exists in the database, the preview user is automatically a member to that workspace -- GitLab