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
......@@ -69,7 +69,7 @@ class FrontendGroupsRepository
$beUser->getPagePermsClause(Permission::PAGE_SHOW)
)
->execute()
->fetchColumn(0);
->fetchOne();
return (int)$optionCount;
}
......
......@@ -76,7 +76,7 @@ class PasswordReset implements LoggerAwareInterface
->from('be_users')
->setMaxResults(1)
->execute();
return (int)$statement->fetchColumn() > 0;
return (int)$statement->fetchOne() > 0;
}
/**
......@@ -96,7 +96,7 @@ class PasswordReset implements LoggerAwareInterface
)
->setMaxResults(1)
->execute();
return $statement->fetchColumn() > 0;
return $statement->fetchOne() > 0;
}
/**
......@@ -490,6 +490,6 @@ class PasswordReset implements LoggerAwareInterface
$queryBuilder->expr()->gte('tstamp', $queryBuilder->createNamedParameter($since->getTimestamp(), \PDO::PARAM_INT))
)
->execute()
->fetchColumn(0);
->fetchOne();
}
}
......@@ -94,7 +94,7 @@ class DefaultAvatarProvider implements AvatarProviderInterface
)
)
->execute()
->fetchColumn();
->fetchOne();
return (int)$fileUid;
}
......
......@@ -166,7 +166,7 @@ class ShortcutRepository
$queryBuilder->expr()->eq('arguments', $queryBuilder->createNamedParameter($arguments))
)
->execute()
->fetchColumn();
->fetchOne();
return (bool)$uid;
}
......
......@@ -1851,7 +1851,7 @@ class EditDocumentController
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......@@ -1874,7 +1874,7 @@ class EditDocumentController
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......
......@@ -413,7 +413,7 @@ class NewRecordController
->count('*')
->from('pages')
->execute()
->fetchColumn(0);
->fetchOne();
if ($numberOfPages > 0) {
$this->code .= '<h3>' . htmlspecialchars($this->getLanguageService()->getLL('selectPosition')) . ':</h3>';
......
......@@ -945,7 +945,7 @@ class PageLayoutController
$count = $queryBuilder
->execute()
->fetchColumn(0);
->fetchOne();
return (int)$count;
}
......
......@@ -17,8 +17,8 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Domain\Repository\Localization;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\ForwardCompatibility\Result;
use Doctrine\DBAL\Statement;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
......@@ -116,7 +116,7 @@ class LocalizationRepository
)
)
->execute()
->fetchColumn(0);
->fetchOne();
return (int)$rowCount;
}
......@@ -205,7 +205,7 @@ class LocalizationRepository
)
->execute();
while ($origUid = $originalUidsStatement->fetchColumn(0)) {
while ($origUid = $originalUidsStatement->fetchOne()) {
$originalUids[] = (int)$origUid;
}
......
......@@ -162,7 +162,7 @@ class SuggestWizardDefaultReceiver
->count('uid')
->resetQueryPart('orderBy')
->execute()
->fetchColumn(0);
->fetchOne();
if ($allRowsCount) {
while ($row = $result->fetch()) {
// check if we already have collected the maximum number of records
......
......@@ -232,7 +232,7 @@ class RecordHistory
)
)
->execute();
$rowCount = (int)$queryBuilder->count('uid')->execute()->fetchColumn(0);
$rowCount = (int)$queryBuilder->count('uid')->execute()->fetchOne();
if ($rowCount === 0) {
continue;
}
......
......@@ -122,7 +122,7 @@ class FailedLoginAttemptNotification
->orderBy('tstamp', 'DESC')
->setMaxResults(1)
->execute();
if ($lastTimeANotificationWasSent = $statement->fetchColumn()) {
if ($lastTimeANotificationWasSent = $statement->fetchOne()) {
$earliestTimeToCheckForFailures = (int)$lastTimeANotificationWasSent;
}
$queryBuilder = $this->createPreparedQueryBuilder($earliestTimeToCheckForFailures, SystemLogLoginAction::ATTEMPT);
......
......@@ -488,7 +488,7 @@ abstract class AbstractTreeView
QueryHelper::stripLogicalOperatorPrefix($this->clause)
)
->execute()
->fetchColumn();
->fetchOne();
return (int)$count;
}
......
......@@ -3180,7 +3180,7 @@ class BackendUtility
}
}
$count = $queryBuilder->execute()->fetchColumn(0);
$count = $queryBuilder->execute()->fetchOne();
}
if ($count) {
......@@ -3222,7 +3222,7 @@ class BackendUtility
)
)
->execute()
->fetchColumn(0);
->fetchOne();
}
if ($count > 0) {
......@@ -3645,7 +3645,7 @@ class BackendUtility
$activeFeGroupId = $queryBuilder->select('uid')
->from('fe_groups')
->execute()
->fetchColumn();
->fetchOne();
if ($activeFeGroupId) {
$simUser = '&ADMCMD_simUser=' . $activeFeGroupId;
......
......@@ -168,7 +168,7 @@ class BackendLayoutView implements SingletonInterface
)
)
->execute()
->fetchColumn();
->fetchOne();
} else {
$pageId = $data['pid'];
}
......
......@@ -15,8 +15,8 @@
namespace TYPO3\CMS\Backend\View;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\ForwardCompatibility\Result;
use Doctrine\DBAL\Statement;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
......
......@@ -45,7 +45,7 @@ class RecordHistoryStoreTest extends FunctionalTestCase
->from('sys_history')
->where($queryBuilder->expr()->eq('correlation_id', $queryBuilder->createNamedParameter((string)$correlationId)))
->execute()
->fetchColumn(0);
->fetchOne();
}
/**
......
......@@ -15,8 +15,8 @@
namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Statement;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSelectItems;
......
......@@ -15,7 +15,7 @@
namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Statement;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSelectTreeItems;
......
......@@ -15,7 +15,7 @@
namespace TYPO3\CMS\Backend\Tests\Unit\Utility;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Statement;
use Prophecy\Argument;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\EventDispatcher\EventDispatcherInterface;
......
......@@ -65,7 +65,7 @@ final class SystemInformationController
)
)
->execute()
->fetchColumn(0);
->fetchOne();
if ($count > 0) {
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
......
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