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
......@@ -67,7 +67,7 @@ class DatabaseService
$queryBuilder->expr()->eq('tablename', $queryBuilder->createNamedParameter('tt_content', \PDO::PARAM_STR))
)
->execute()
->fetchAll();
->fetchAllAssociative();
}
/**
......@@ -132,6 +132,6 @@ class DatabaseService
->where(...$constraints)
->groupBy($column)
->execute()
->fetchAll();
->fetchAllAssociative();
}
}
......@@ -338,7 +338,7 @@ class AdministrationController extends ActionController
)
->orderBy('index_words.baseword')
->execute()
->fetchAll();
->fetchAllAssociative();
foreach ($wordRecords as $id => $row) {
if (isset($keywords[$row['baseword']])) {
$wordRecords[$id]['is_keyword'] = true;
......@@ -374,7 +374,7 @@ class AdministrationController extends ActionController
)
)
->execute()
->fetchAll();
->fetchAllAssociative();
// top words
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_words');
......@@ -399,7 +399,7 @@ class AdministrationController extends ActionController
)
->orderBy('index_rel.count', 'DESC')
->execute()
->fetchAll();
->fetchAllAssociative();
// top frequency
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('index_words');
......@@ -424,7 +424,7 @@ class AdministrationController extends ActionController
)
->orderBy('index_rel.freq', 'DESC')
->execute()
->fetchAll();
->fetchAllAssociative();
$this->view->assignMultiple([
'phash' => (int)$pageHash,
......@@ -495,7 +495,7 @@ class AdministrationController extends ActionController
)
->orderBy('index_rel.freq', 'desc')
->execute()
->fetchAll();
->fetchAllAssociative();
$this->view->assignMultiple([
'rows' => $rows,
......
......@@ -287,7 +287,7 @@ class AdministrationRepository
)
->groupBy('phash_grouping')
->execute()
->fetchAll();
->fetchAllAssociative();
return count($items);
}
......@@ -438,7 +438,7 @@ class AdministrationRepository
);
}
return $queryBuilder->execute()->fetchAll();
return $queryBuilder->execute()->fetchAllAssociative();
}
/**
......@@ -629,7 +629,7 @@ class AdministrationRepository
->groupBy('index_words.baseword')
->orderBy('index_words.baseword')
->execute()
->fetchAll();
->fetchAllAssociative();
if (is_array($wordRecords)) {
$row['allWords'] = array_column($wordRecords, 'baseword');
......
......@@ -185,7 +185,7 @@ class SettingsController extends AbstractController
)
->orderBy('uid')
->execute()
->fetchAll();
->fetchAllAssociative();
$systemMaintainerList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemMaintainers'] ?? [];
$systemMaintainerList = array_map('intval', $systemMaintainerList);
......@@ -240,7 +240,7 @@ class SettingsController extends AbstractController
$queryBuilder->expr()->eq('admin', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)),
$queryBuilder->expr()->in('uid', $queryBuilder->createNamedParameter($newUserList, Connection::PARAM_INT_ARRAY))
)
)->execute()->fetchAll();
)->execute()->fetchAllAssociative();
$validatedUserList = array_column($validatedUserList, 'uid');
$validatedUserList = array_map('intval', $validatedUserList);
......
......@@ -1266,7 +1266,7 @@ class UpgradeController extends AbstractController
)
)
->execute()
->fetchAll();
->fetchAllAssociative();
$hashesMarkedAsRead = [];
foreach ($filesMarkedAsRead as $file) {
$hashesMarkedAsRead[] = $file['entry_key'];
......@@ -1282,7 +1282,7 @@ class UpgradeController extends AbstractController
)
)
->execute()
->fetchAll();
->fetchAllAssociative();
$hashesMarkedAsNotAffected = [];
foreach ($fileMarkedAsNotAffected as $file) {
$hashesMarkedAsNotAffected[] = $file['entry_key'];
......
......@@ -93,7 +93,7 @@ class BackendUserLanguageMigration implements UpgradeWizardInterface
protected function getRecordsToUpdate(): array
{
return $this->getPreparedQueryBuilder()->select(...['uid', 'uc', 'lang'])->execute()->fetchAll();
return $this->getPreparedQueryBuilder()->select(...['uid', 'uc', 'lang'])->execute()->fetchAllAssociative();
}
protected function getPreparedQueryBuilder(): QueryBuilder
......
......@@ -126,7 +126,7 @@ class ShortcutRecordsMigration implements UpgradeWizardInterface
protected function getRecordsToUpdate(): array
{
return $this->getPreparedQueryBuilder()->select(...['uid', 'module_name', 'url'])->execute()->fetchAll();
return $this->getPreparedQueryBuilder()->select(...['uid', 'module_name', 'url'])->execute()->fetchAllAssociative();
}
protected function getPreparedQueryBuilder(): QueryBuilder
......
......@@ -258,7 +258,7 @@ class BrokenLinkRepository
->orderBy('tx_linkvalidator_link.record_uid')
->addOrderBy('tx_linkvalidator_link.uid')
->execute()
->fetchAll();
->fetchAllAssociative();
foreach ($records as &$record) {
$response = json_decode($record['url_response'], true);
// Fallback mechanism to still support the old serialized data, could be removed in TYPO3 v12 or later
......
......@@ -356,7 +356,7 @@ class QueryGenerator
// EXPLAIN is no ANSI SQL, for now this is only executed on mysql
// @todo: Move away from getSelectQuery() or model differently
$fullQueryString = 'EXPLAIN ' . $selectQueryString;
$dataRows = $connection->executeQuery('EXPLAIN ' . $selectQueryString)->fetchAll();
$dataRows = $connection->executeQuery('EXPLAIN ' . $selectQueryString)->fetchAllAssociative();
} elseif ($mQ === 'count') {
$queryBuilder = $connection->createQueryBuilder();
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
......@@ -367,7 +367,7 @@ class QueryGenerator
$dataRows = [$queryBuilder->execute()->fetchOne()];
} else {
$fullQueryString = $selectQueryString;
$dataRows = $connection->executeQuery($selectQueryString)->fetchAll();
$dataRows = $connection->executeQuery($selectQueryString)->fetchAllAssociative();
}
if (!($userTsConfig['mod.']['dbint.']['disableShowSQLQuery'] ?? false)) {
$output .= '<h2>SQL query</h2><div><pre>' . htmlspecialchars($fullQueryString) . '</pre></div>';
......
......@@ -172,7 +172,7 @@ class PageLinkHandler extends AbstractLinkHandler implements LinkHandlerInterfac
->orderBy('colPos')
->addOrderBy('sorting')
->execute()
->fetchAll();
->fetchAllAssociative();
// Enrich list of records
foreach ($contentElements as &$contentElement) {
......
......@@ -240,7 +240,7 @@ class DeletedRecords
)
->orderBy('uid')
->execute()
->fetchAll();
->fetchAllAssociative();
if ($recordsToCheck !== false) {
$this->checkRecordAccess($table, $recordsToCheck);
......
......@@ -38,7 +38,7 @@ class RedirectRepository
->setMaxResults($demand->getLimit())
->setFirstResult($demand->getOffset())
->execute()
->fetchAll();
->fetchAllAssociative();
}
public function countRedirectsByByDemand(Demand $demand): int
......@@ -125,7 +125,7 @@ class RedirectRepository
->orderBy('source_host')
->groupBy('source_host')
->execute()
->fetchAll();
->fetchAllAssociative();
}
/**
......@@ -139,7 +139,7 @@ class RedirectRepository
->orderBy('target_statuscode')
->groupBy('target_statuscode')
->execute()
->fetchAll();
->fetchAllAssociative();
}
protected function getQueryBuilder(): QueryBuilder
......
......@@ -214,7 +214,7 @@ class SlugService implements LoggerAwareInterface
)
->orderBy('uid', 'ASC')
->execute()
->fetchAll();
->fetchAllAssociative();
// if the language is not the default language, resolve the language related records.
if ($languageUid > 0) {
......@@ -228,7 +228,7 @@ class SlugService implements LoggerAwareInterface
)
->orderBy('uid', 'ASC')
->execute()
->fetchAll();
->fetchAllAssociative();
}
$results = [];
if (!empty($subPages)) {
......
......@@ -109,7 +109,7 @@ class FalStatus implements StatusProviderInterface
)
->setMaxResults($maxFilesToShow)
->execute()
->fetchAll();
->fetchAllAssociative();
$message = '<p>' . $this->getLanguageService()->getLL('status_missingFilesMessage') . '</p>';
foreach ($files as $file) {
......
......@@ -1291,7 +1291,7 @@ class SchedulerModuleController
->from('tx_scheduler_task_group')
->orderBy('sorting')
->execute()
->fetchAll();
->fetchAllAssociative();
}
/**
......
......@@ -227,7 +227,7 @@ class OptimizeDatabaseTableAdditionalFieldProvider extends AbstractAdditionalFie
);
}
$tables = $queryBuilder->execute()->fetchAll();
$tables = $queryBuilder->execute()->fetchAllAssociative();
return array_column($tables, 'Table');
}
......
......@@ -102,7 +102,7 @@ class PagesXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
->where(...$constraints)
->orderBy('uid', 'ASC')
->execute()
->fetchAll();
->fetchAllAssociative();
return $pages;
}
......
......@@ -117,7 +117,7 @@ class RecordsXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
$rows = $queryBuilder->orderBy($sortField)
->execute()
->fetchAll();
->fetchAllAssociative();
foreach ($rows as $row) {
$item = [
......
......@@ -78,6 +78,6 @@ class SysNoteRepository
);
}
return $res->execute()->fetchAll();
return $res->execute()->fetchAllAssociative();
}
}
......@@ -84,7 +84,7 @@ class RecordService implements SingletonInterface
)
->groupBy($createUserIdFieldName)
->execute()
->fetchAll();
->fetchAllAssociative();
$records = array_column($records, $createUserIdFieldName);
......
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