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