Commit d6fa37ea authored by Benni Mack's avatar Benni Mack Committed by Oliver Bartsch
Browse files

[TASK] Replace fetchColumn with fetchOne for Doctrine DBAL

This change replaces all query results from the
database from fetchColumn() to fetchOne(), as this
is the new API used in Doctrine DBAL.

This change is one of a few to prepare for
Doctrine DBAL 3.0 compatibility.

Resolves: #94605
Releases: master
Change-Id: Ia9ca2bbb7b2c16a230c5946941cc3023203f494d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69917


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent b6c2a5ea
......@@ -17,7 +17,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Impexp\Controller;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Statement;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
......
......@@ -76,7 +76,7 @@ class AdministrationRepository
$numberOfRows = $queryBuilder
->count('uniqid')
->execute()
->fetchColumn(0);
->fetchOne();
$allRows = [];
while ($row = $result->fetch()) {
$row['pcount'] = $numberOfRows;
......@@ -104,7 +104,7 @@ class AdministrationRepository
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......@@ -126,7 +126,7 @@ class AdministrationRepository
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......@@ -223,7 +223,7 @@ class AdministrationRepository
->count('*')
->from($tableName)
->execute()
->fetchColumn(0);
->fetchOne();
}
return $recordList;
}
......@@ -311,7 +311,7 @@ class AdministrationRepository
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......@@ -420,7 +420,7 @@ class AdministrationRepository
$count = (int)$countQueryBuilder
->count('uid')
->execute()
->fetchColumn(0);
->fetchOne();
$result->closeCursor();
// exist several statistics for this page?
......@@ -593,7 +593,7 @@ class AdministrationRepository
$row['wordCount'] = $queryBuilder
->count('index_rel.wid')
->execute()
->fetchColumn(0);
->fetchOne();
$wordCountResult->closeCursor();
if ($mode === 'content') {
......
......@@ -15,7 +15,7 @@
namespace TYPO3\CMS\IndexedSearch\Domain\Repository;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Statement;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\Connection;
......
......@@ -1449,7 +1449,7 @@ class Indexer
)
)
->execute()
->fetchColumn();
->fetchOne();
if ($count === 0) {
$this->submit_grlist($hash, $hash);
......@@ -1483,7 +1483,7 @@ class Indexer
)
)
->execute()
->fetchColumn();
->fetchOne();
if ($count === 0) {
$this->submit_section($hash, $this->hash['phash']);
......@@ -1837,7 +1837,7 @@ class Indexer
)
)
->execute()
->fetchColumn();
->fetchOne();
if ($count !== $wordListArrayCount) {
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('index_words');
......
......@@ -352,7 +352,7 @@ class PageInformationController
if ($depth >= 0) {
$result = $queryBuilder->execute();
$rowCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
$rowCount = $queryBuilder->count('uid')->execute()->fetchOne();
$count = 0;
while ($row = $result->fetch()) {
BackendUtility::workspaceOL('pages', $row);
......@@ -533,7 +533,7 @@ class PageInformationController
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT))
)
->execute()
->fetchColumn();
->fetchOne();
}
return $count;
......
......@@ -423,7 +423,7 @@ class TranslationStatusController
$row = $result->fetch();
BackendUtility::workspaceOL('pages', $row);
if (is_array($row)) {
$row['_COUNT'] = $queryBuilder->count('uid')->execute()->fetchColumn(0);
$row['_COUNT'] = $queryBuilder->count('uid')->execute()->fetchOne();
$row['_HIDDEN'] = $row['hidden'] || (int)$row['endtime'] > 0 && (int)$row['endtime'] < $GLOBALS['EXEC_TIME'] || $GLOBALS['EXEC_TIME'] < (int)$row['starttime'];
}
$result->closeCursor();
......@@ -461,7 +461,7 @@ class TranslationStatusController
)
)
->execute()
->fetchColumn(0);
->fetchOne();
return $count ?: '-';
}
......
......@@ -235,7 +235,7 @@ class UpgradeWizardsService
)
->setMaxResults(1)
->execute()
->fetchColumn();
->fetchOne();
// check if database charset is utf-8, also allows utf8mb4
$charsetOk = strpos($charset, 'utf8') === 0;
}
......
......@@ -160,7 +160,7 @@ class MySql extends AbstractPlatform
)
->setMaxResults(1)
->execute()
->fetchColumn();
->fetchOne();
if (!in_array($defaultDatabaseCharset, $this->databaseCharsetToCheck, true)) {
$this->messageQueue->enqueue(new FlashMessage(
......
......@@ -88,7 +88,7 @@ class BackendUserLanguageMigration implements UpgradeWizardInterface
return (bool)$queryBuilder
->count('uid')
->execute()
->fetchColumn();
->fetchOne();
}
protected function getRecordsToUpdate(): array
......
......@@ -118,7 +118,7 @@ class CollectionsExtractionUpdate extends AbstractDownloadExtensionUpdate
$numberOfEntries = $queryBuilder->count('*')
->from('sys_collection')
->execute()
->fetchColumn();
->fetchOne();
return (bool)$numberOfEntries;
}
......
......@@ -121,7 +121,7 @@ class ShortcutRecordsMigration implements UpgradeWizardInterface
protected function hasRecordsToUpdate(): bool
{
return (bool)$this->getPreparedQueryBuilder()->count('uid')->execute()->fetchColumn();
return (bool)$this->getPreparedQueryBuilder()->count('uid')->execute()->fetchOne();
}
protected function getRecordsToUpdate(): array
......
......@@ -50,7 +50,7 @@ class BrokenLinkRepository
);
return (bool)$queryBuilder
->execute()
->fetchColumn(0);
->fetchOne();
} catch (TableNotFoundException $e) {
return false;
}
......
......@@ -166,7 +166,7 @@ class DeletedRecordsCommand extends Command
$rowCount = $queryBuilderForPages
->count('uid')
->execute()
->fetchColumn(0);
->fetchOne();
// Register if page itself is deleted
if ($rowCount > 0) {
$deletedRecords['pages'][$pageId] = $pageId;
......
......@@ -255,7 +255,7 @@ If you want to get more detailed information, use the --verbose option.')
->orderBy('sorting', 'DESC')
->execute();
$rowCount = $queryBuilder->count('hash')->execute()->fetchColumn(0);
$rowCount = $queryBuilder->count('hash')->execute()->fetchOne();
// We conclude that the file is lost
if ($rowCount === 0) {
$lostFiles[] = $value;
......
......@@ -119,7 +119,7 @@ Manual repair suggestions:
->orderBy('uid')
->execute();
$rowCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
$rowCount = $queryBuilder->count('uid')->execute()->fetchOne();
if ($rowCount) {
$orphans[$tableName] = [];
while ($orphanRecord = $result->fetch()) {
......
......@@ -374,7 +374,7 @@ class QueryGenerator
->from($this->table)
->where(QueryHelper::stripLogicalOperatorPrefix($queryString));
$fullQueryString = $queryBuilder->getSQL();
$dataRows = [$queryBuilder->execute()->fetchColumn(0)];
$dataRows = [$queryBuilder->execute()->fetchOne()];
} else {
$fullQueryString = $selectQueryString;
$dataRows = $connection->executeQuery($selectQueryString)->fetchAll();
......@@ -434,7 +434,7 @@ class QueryGenerator
$queryBuilder->createNamedParameter($escapedLikeString, \PDO::PARAM_STR)
);
}
$count = $queryBuilder->orWhere(...$likes)->execute()->fetchColumn(0);
$count = $queryBuilder->orWhere(...$likes)->execute()->fetchOne();
if ($count > 0) {
$queryBuilder = $connection->createQueryBuilder();
......@@ -618,7 +618,7 @@ class QueryGenerator
$rowCount = $queryBuilder->count('*')
->from($this->table)
->where(QueryHelper::stripLogicalOperatorPrefix($queryString))
->execute()->fetchColumn(0);
->execute()->fetchOne();
$t2DataValue = [
'qC' => $saveArr,
......
......@@ -325,7 +325,7 @@ class DatabaseIntegrityCheck
)
)
->execute()
->fetchColumn(0);
->fetchOne();
if ($count) {
$list[$table] = $count;
}
......@@ -344,7 +344,7 @@ class DatabaseIntegrityCheck
)
)
->execute()
->fetchColumn(0);
->fetchOne();
if ($count) {
$list_n[$table] = $count;
}
......
......@@ -549,7 +549,7 @@ class DatabaseRecordList
$queryBuilderTotalItems = $this->getQueryBuilder($table, $id, [], ['*'], false, 0, 1);
$totalItems = (int)$queryBuilderTotalItems->count('*')
->execute()
->fetchColumn();
->fetchOne();
if ($totalItems === 0) {
return '';
}
......
......@@ -284,7 +284,7 @@ class RecyclerAjaxController
)
->setMaxResults(1);
return (int)$queryBuilder->execute()->fetchColumn(0);
return (int)$queryBuilder->execute()->fetchOne();
}
/**
......
......@@ -174,7 +174,7 @@ class DeletedRecords
)
)
->execute()
->fetchColumn(0);
->fetchOne();
// split the limit
[$offset, $rowCount] = GeneralUtility::intExplode(',', $this->limit, true);
......
Supports Markdown
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