Commit cfb31933 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[TASK] Migrate Doctrine DBAL fetchAll() to fetchAllAssociative()

Since TYPO3 uses the \PDO::FETCH_ASSOC fetch mode
by default, fetchAll() is the equivalent for fetchAllAssociative()
which is the new API for Doctrine 3. In order to
move towards the new Doctrine DBAL 3.x API,
this change migrates all fetchAll() calls
to fetchAllAssociative() or fetchFirstColumn().

Resolves: #94618
Releases: master
Change-Id: I2ab4db871d0b65ad07e629b54bb79b1c3b411005
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70016

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 3748cafd
...@@ -98,7 +98,7 @@ class FrontendGroupsRepository ...@@ -98,7 +98,7 @@ class FrontendGroupsRepository
) )
->orderBy('fe_groups.title') ->orderBy('fe_groups.title')
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
} }
/** /**
......
...@@ -128,7 +128,7 @@ class PasswordReset implements LoggerAwareInterface ...@@ -128,7 +128,7 @@ class PasswordReset implements LoggerAwareInterface
$queryBuilder->expr()->eq('email', $queryBuilder->createNamedParameter($emailAddress)) $queryBuilder->expr()->eq('email', $queryBuilder->createNamedParameter($emailAddress))
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
if (!is_array($users) || count($users) === 0) { if (!is_array($users) || count($users) === 0) {
// No user found, do nothing, also no log to sys_log in order avoid log flooding // No user found, do nothing, also no log to sys_log in order avoid log flooding
$this->logger->warning('Password reset requested for email but no valid users'); $this->logger->warning('Password reset requested for email but no valid users');
......
...@@ -444,7 +444,7 @@ class Clipboard ...@@ -444,7 +444,7 @@ class Clipboard
GeneralUtility::makeInstance(WorkspaceRestriction::class, $workspaceId) GeneralUtility::makeInstance(WorkspaceRestriction::class, $workspaceId)
); );
} }
$rows = $queryBuilder->execute()->fetchAll(); $rows = $queryBuilder->execute()->fetchAllAssociative();
if (is_array($rows)) { if (is_array($rows)) {
foreach ($rows as $rec) { foreach ($rows as $rec) {
$lines[] = [ $lines[] = [
......
...@@ -182,7 +182,7 @@ class TranslationConfigurationProvider ...@@ -182,7 +182,7 @@ class TranslationConfigurationProvider
} }
$translationRecords = $queryBuilder $translationRecords = $queryBuilder
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
$translations = []; $translations = [];
$translationsErrors = []; $translationsErrors = [];
......
...@@ -685,7 +685,7 @@ class ElementInformationController ...@@ -685,7 +685,7 @@ class ElementInformationController
->from('sys_refindex') ->from('sys_refindex')
->where(...$predicates) ->where(...$predicates)
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
// Compile information for title tag: // Compile information for title tag:
foreach ($rows as $row) { foreach ($rows as $row) {
...@@ -776,7 +776,7 @@ class ElementInformationController ...@@ -776,7 +776,7 @@ class ElementInformationController
->from('sys_refindex') ->from('sys_refindex')
->where(...$predicates) ->where(...$predicates)
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
// Compile information for title tag: // Compile information for title tag:
foreach ($rows as $row) { foreach ($rows as $row) {
......
...@@ -463,7 +463,7 @@ class LoginController ...@@ -463,7 +463,7 @@ class LoginController
->from($systemNewsTable) ->from($systemNewsTable)
->orderBy('crdate', 'DESC') ->orderBy('crdate', 'DESC')
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
foreach ($systemNewsRecords as $systemNewsRecord) { foreach ($systemNewsRecords as $systemNewsRecord) {
$systemNews[] = [ $systemNews[] = [
'uid' => $systemNewsRecord['uid'], 'uid' => $systemNewsRecord['uid'],
......
...@@ -233,7 +233,7 @@ class LocalizationController ...@@ -233,7 +233,7 @@ class LocalizationController
'uid' 'uid'
); );
return array_intersect(array_unique($transmittedUidList), array_column($validUidList->fetchAll(), 'uid')); return array_intersect(array_unique($transmittedUidList), array_column($validUidList->fetchAllAssociative(), 'uid'));
} }
/** /**
......
...@@ -264,7 +264,7 @@ class NewMultiplePagesController ...@@ -264,7 +264,7 @@ class NewMultiplePagesController
) )
->orderBy('sorting') ->orderBy('sorting')
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
} }
/** /**
......
...@@ -215,7 +215,7 @@ class SortSubPagesController ...@@ -215,7 +215,7 @@ class SortSubPagesController
) )
->orderBy($orderBy) ->orderBy($orderBy)
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
} }
/** /**
......
...@@ -490,7 +490,7 @@ class PageLayoutController ...@@ -490,7 +490,7 @@ class PageLayoutController
->where($queryBuilder->expr()->eq('content_from_pid', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT))); ->where($queryBuilder->expr()->eq('content_from_pid', $queryBuilder->createNamedParameter($pageId, \PDO::PARAM_INT)));
$links = []; $links = [];
$rows = $queryBuilder->execute()->fetchAll(); $rows = $queryBuilder->execute()->fetchAllAssociative();
if (!empty($rows)) { if (!empty($rows)) {
foreach ($rows as $row) { foreach ($rows as $row) {
$linkToPid = GeneralUtility::linkThisScript(['id' => $row['uid']]); $linkToPid = GeneralUtility::linkThisScript(['id' => $row['uid']]);
......
...@@ -146,7 +146,7 @@ class LocalizationRepository ...@@ -146,7 +146,7 @@ class LocalizationRepository
->groupBy('sys_language_uid'); ->groupBy('sys_language_uid');
$this->getAllowedLanguageConstraintsForBackendUser($pageId, $queryBuilder, $this->getBackendUser()); $this->getAllowedLanguageConstraintsForBackendUser($pageId, $queryBuilder, $this->getBackendUser());
$languages = $queryBuilder->execute()->fetchAll(); $languages = $queryBuilder->execute()->fetchAllAssociative();
return $languages ?: []; return $languages ?: [];
} }
......
...@@ -69,7 +69,7 @@ class DatabasePageLanguageOverlayRows implements FormDataProviderInterface ...@@ -69,7 +69,7 @@ class DatabasePageLanguageOverlayRows implements FormDataProviderInterface
$queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT) $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
)) ))
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
return $rows; return $rows;
} }
......
...@@ -253,7 +253,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface ...@@ -253,7 +253,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface
) )
->groupBy($languageField, 'uid') ->groupBy($languageField, 'uid')
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
if (!empty($possibleRecords)) { if (!empty($possibleRecords)) {
// Either only one record or first record matches language // Either only one record or first record matches language
......
...@@ -130,7 +130,7 @@ class FailedLoginAttemptNotification ...@@ -130,7 +130,7 @@ class FailedLoginAttemptNotification
->select('*') ->select('*')
->orderBy('tstamp') ->orderBy('tstamp')
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
return is_array($previousFailures) ? $previousFailures : []; return is_array($previousFailures) ? $previousFailures : [];
} }
......
...@@ -220,7 +220,7 @@ class PageTreeRepository ...@@ -220,7 +220,7 @@ class PageTreeRepository
QueryHelper::stripLogicalOperatorPrefix($GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)) QueryHelper::stripLogicalOperatorPrefix($GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW))
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
// This is necessary to resolve all IDs in a workspace // This is necessary to resolve all IDs in a workspace
if ($this->currentWorkspace !== 0 && !empty($pageRecords)) { if ($this->currentWorkspace !== 0 && !empty($pageRecords)) {
...@@ -259,7 +259,7 @@ class PageTreeRepository ...@@ -259,7 +259,7 @@ class PageTreeRepository
$queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter($recordIds, Connection::PARAM_INT_ARRAY)) $queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter($recordIds, Connection::PARAM_INT_ARRAY))
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
foreach ($pageRecords as &$pageRecord) { foreach ($pageRecords as &$pageRecord) {
if ((int)$pageRecord['t3ver_state'] === VersionState::MOVE_POINTER && !empty($movedPages[$pageRecord['t3ver_oid']])) { if ((int)$pageRecord['t3ver_state'] === VersionState::MOVE_POINTER && !empty($movedPages[$pageRecord['t3ver_oid']])) {
...@@ -330,7 +330,7 @@ class PageTreeRepository ...@@ -330,7 +330,7 @@ class PageTreeRepository
); );
} }
$pageRecords = $query->execute()->fetchAll(); $pageRecords = $query->execute()->fetchAllAssociative();
$ids = array_column($pageRecords, 'uid'); $ids = array_column($pageRecords, 'uid');
foreach ($dbMounts as $mount) { foreach ($dbMounts as $mount) {
...@@ -380,7 +380,7 @@ class PageTreeRepository ...@@ -380,7 +380,7 @@ class PageTreeRepository
$queryBuilder->expr()->in('uid', $recordIds) $queryBuilder->expr()->in('uid', $recordIds)
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
} }
// Now set up sorting, nesting (tree-structure) for all pages based on pid+sorting fields // Now set up sorting, nesting (tree-structure) for all pages based on pid+sorting fields
...@@ -523,7 +523,7 @@ class PageTreeRepository ...@@ -523,7 +523,7 @@ class PageTreeRepository
$queryBuilder->andWhere($searchParts); $queryBuilder->andWhere($searchParts);
$pageRecords = $queryBuilder $pageRecords = $queryBuilder
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
$livePagePids = []; $livePagePids = [];
if ($this->currentWorkspace !== 0 && !empty($pageRecords)) { if ($this->currentWorkspace !== 0 && !empty($pageRecords)) {
...@@ -565,7 +565,7 @@ class PageTreeRepository ...@@ -565,7 +565,7 @@ class PageTreeRepository
$queryBuilder->andWhere($searchParts); $queryBuilder->andWhere($searchParts);
$pageRecords = $queryBuilder $pageRecords = $queryBuilder
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
} }
} }
......
...@@ -318,7 +318,7 @@ class BackendUtility ...@@ -318,7 +318,7 @@ class BackendUtility
$queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($andWhereClause)); $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($andWhereClause));
} }
$recordLocalization = $queryBuilder->execute()->fetchAll(); $recordLocalization = $queryBuilder->execute()->fetchAllAssociative();
} }
return $recordLocalization; return $recordLocalization;
...@@ -3319,7 +3319,7 @@ class BackendUtility ...@@ -3319,7 +3319,7 @@ class BackendUtility
); );
} }
$rows = $queryBuilder->execute()->fetchAll(); $rows = $queryBuilder->execute()->fetchAllAssociative();
// Add rows to output array: // Add rows to output array:
if (is_array($rows)) { if (is_array($rows)) {
......
...@@ -232,7 +232,7 @@ class LocalizationRepositoryTest extends FunctionalTestCase ...@@ -232,7 +232,7 @@ class LocalizationRepositoryTest extends FunctionalTestCase
public function getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult): void public function getRecordsToCopyDatabaseResult(int $pageId, int $destLanguageId, int $languageId, array $expectedResult): void
{ {
$result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $destLanguageId, $languageId, 'uid'); $result = $this->subject->getRecordsToCopyDatabaseResult($pageId, $destLanguageId, $languageId, 'uid');
$result = $result->fetchAll(); $result = $result->fetchAllAssociative();
self::assertEquals($expectedResult, $result); self::assertEquals($expectedResult, $result);
} }
} }
...@@ -728,7 +728,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication ...@@ -728,7 +728,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
) )
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
foreach ($recordLocalizations as $recordLocalization) { foreach ($recordLocalizations as $recordLocalization) {
if (!$this->checkLanguageAccess($recordLocalization[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) { if (!$this->checkLanguageAccess($recordLocalization[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
...@@ -1363,7 +1363,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication ...@@ -1363,7 +1363,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
) )
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
$readablePagesOfWebMounts = array_column(($readablePagesOfWebMounts ?: []), 'uid', 'uid'); $readablePagesOfWebMounts = array_column(($readablePagesOfWebMounts ?: []), 'uid', 'uid');
foreach ($allWebMounts as $key => $mountPointUid) { foreach ($allWebMounts as $key => $mountPointUid) {
// If the mount ID is NOT found among selected pages, unset it: // If the mount ID is NOT found among selected pages, unset it:
...@@ -1527,7 +1527,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email']; ...@@ -1527,7 +1527,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
$queryBuilder->addOrderBy(...$fieldAndDirection); $queryBuilder->addOrderBy(...$fieldAndDirection);
} }
$fileMountRecords = $queryBuilder->execute()->fetchAll(\PDO::FETCH_ASSOC); $fileMountRecords = $queryBuilder->execute()->fetchAllAssociative();
if ($fileMountRecords !== false) { if ($fileMountRecords !== false) {
foreach ($fileMountRecords as $fileMount) { foreach ($fileMountRecords as $fileMount) {
$fileMountRecordCache[$fileMount['base'] . $fileMount['path']] = $fileMount; $fileMountRecordCache[$fileMount['base'] . $fileMount['path']] = $fileMount;
......
...@@ -167,7 +167,7 @@ class GroupResolver ...@@ -167,7 +167,7 @@ class GroupResolver
$queryBuilder->expr()->orX(...$constraints) $queryBuilder->expr()->orX(...$constraints)
) )
->execute() ->execute()
->fetchAll(); ->fetchAllAssociative();
return !empty($users) ? $users : []; return !empty($users) ? $users : [];
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
namespace TYPO3\CMS\Core\Cache\Backend; namespace TYPO3\CMS\Core\Cache\Backend;
use Doctrine\DBAL\FetchMode;
use TYPO3\CMS\Core\Cache\Exception; use TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Exception\InvalidDataException; use TYPO3\CMS\Core\Cache\Exception\InvalidDataException;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
...@@ -240,7 +239,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt ...@@ -240,7 +239,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt
) )
->groupBy($this->cacheTable . '.identifier') ->groupBy($this->cacheTable . '.identifier')
->execute(); ->execute();
$identifiers = $result->fetchAll(FetchMode::COLUMN, 0); $identifiers = $result->fetchFirstColumn();
return array_combine($identifiers, $identifiers); return array_combine($identifiers, $identifiers);
} }
...@@ -308,7 +307,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt ...@@ -308,7 +307,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt
// group by is like DISTINCT and used here to suppress possible duplicate identifiers // group by is like DISTINCT and used here to suppress possible duplicate identifiers
->groupBy('identifier') ->groupBy('identifier')
->execute(); ->execute();
$cacheEntryIdentifiers = $result->fetchAll(FetchMode::COLUMN, 0); $cacheEntryIdentifiers = $result->fetchFirstColumn();
$quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY); $quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY);
$queryBuilder->delete($this->cacheTable) $queryBuilder->delete($this->cacheTable)
->where($queryBuilder->expr()->in('identifier', $quotedIdentifiers)) ->where($queryBuilder->expr()->in('identifier', $quotedIdentifiers))
...@@ -356,7 +355,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt ...@@ -356,7 +355,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt
// group by is like DISTINCT and used here to suppress possible duplicate identifiers // group by is like DISTINCT and used here to suppress possible duplicate identifiers
->groupBy('identifier') ->groupBy('identifier')
->execute(); ->execute();
$cacheEntryIdentifiers = $result->fetchAll(FetchMode::COLUMN, 0); $cacheEntryIdentifiers = $result->fetchFirstColumn();
$quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY); $quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY);
$queryBuilder->delete($this->cacheTable) $queryBuilder->delete($this->cacheTable)
->where($queryBuilder->expr()->in('identifier', $quotedIdentifiers)) ->where($queryBuilder->expr()->in('identifier', $quotedIdentifiers))
...@@ -407,7 +406,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt ...@@ -407,7 +406,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt
->execute(); ->execute();
// Get identifiers of expired cache entries // Get identifiers of expired cache entries
$cacheEntryIdentifiers = $result->fetchAll(FetchMode::COLUMN, 0); $cacheEntryIdentifiers = $result->fetchFirstColumn();
if (!empty($cacheEntryIdentifiers)) { if (!empty($cacheEntryIdentifiers)) {
// Delete tag rows connected to expired cache entries // Delete tag rows connected to expired cache entries
$quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY); $quotedIdentifiers = $queryBuilder->createNamedParameter($cacheEntryIdentifiers, Connection::PARAM_STR_ARRAY);
...@@ -435,7 +434,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt ...@@ -435,7 +434,7 @@ class Typo3DatabaseBackend extends AbstractBackend implements TaggableBackendInt
->where($queryBuilder->expr()->isNull('cache.identifier')) ->where($queryBuilder->expr()->isNull('cache.identifier'))
->groupBy('tags.identifier') ->groupBy('tags.identifier')
->execute(); ->execute();
$tagsEntryIdentifiers = $result->fetchAll(FetchMode::COLUMN, 0); $tagsEntryIdentifiers = $result->fetchFirstColumn();
if (!empty($tagsEntryIdentifiers)) { if (!empty($tagsEntryIdentifiers)) {
$quotedIdentifiers = $queryBuilder->createNamedParameter($tagsEntryIdentifiers, Connection::PARAM_STR_ARRAY); $quotedIdentifiers = $queryBuilder->createNamedParameter($tagsEntryIdentifiers, Connection::PARAM_STR_ARRAY);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment