From 35203576ed2b612c8ac0e90bfa714caab3e602cc Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 16 Jan 2024 15:38:44 +0100 Subject: [PATCH] [BUGFIX] Migrate usages of the PDO param type constants In TYPO3 code, the TYPO3 `Connection` constants should be used instead. --- .../RecordList/RecordListConstraint.php | 5 ++-- .../DataProcessing/AddNewsToMenuProcessor.php | 3 +- Classes/Database/QueryGenerator.php | 3 +- .../Repository/AdministrationRepository.php | 2 +- .../Domain/Repository/CategoryRepository.php | 4 +-- ...fyDatabaseQueryForContentEventListener.php | 3 +- ...baseQueryForRecordListingEventListener.php | 3 +- Classes/Hooks/Backend/PageViewQueryHook.php | 3 +- Classes/Seo/NewsAvailability.php | 21 ++++++------- Classes/Seo/NewsXmlSitemapDataProvider.php | 6 ++-- Classes/Service/AccessControlService.php | 13 ++++---- Classes/Service/CategoryService.php | 4 +-- .../Service/LinkHandlerTargetPageService.php | 7 +++-- Classes/Service/SlugService.php | 30 +++++++++---------- Classes/Updates/PopulateCategorySlugs.php | 3 +- Classes/Updates/PopulateTagSlugs.php | 3 +- .../ViewHelpers/Category/CountViewHelper.php | 6 ++-- .../ViewHelpers/SimplePrevNextViewHelper.php | 18 +++++------ Classes/ViewHelpers/Tag/CountViewHelper.php | 3 +- .../SimplePrevNextViewHelperTest.php | 3 +- 20 files changed, 78 insertions(+), 65 deletions(-) diff --git a/Classes/Backend/RecordList/RecordListConstraint.php b/Classes/Backend/RecordList/RecordListConstraint.php index 9ce0ecee96..513533d210 100644 --- a/Classes/Backend/RecordList/RecordListConstraint.php +++ b/Classes/Backend/RecordList/RecordListConstraint.php @@ -12,6 +12,7 @@ use GeorgRinger\News\Service\CategoryService; use GeorgRinger\News\Utility\ConstraintHelper; use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; @@ -245,9 +246,9 @@ protected function getNewsIdsOfCategory($categoryId): array $queryBuilder->expr()->eq('sys_category.uid', $queryBuilder->quoteIdentifier('sys_category_record_mm.uid_local')) ) ->where( - $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), + $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)), $queryBuilder->expr()->isNotNull('tx_news_domain_model_news.uid'), - $queryBuilder->expr()->eq('sys_category.uid', $queryBuilder->createNamedParameter($categoryId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_category.uid', $queryBuilder->createNamedParameter($categoryId, Connection::PARAM_INT)) ) ->executeQuery(); diff --git a/Classes/DataProcessing/AddNewsToMenuProcessor.php b/Classes/DataProcessing/AddNewsToMenuProcessor.php index 420ff1bf3e..bc5cd9b5e2 100644 --- a/Classes/DataProcessing/AddNewsToMenuProcessor.php +++ b/Classes/DataProcessing/AddNewsToMenuProcessor.php @@ -14,6 +14,7 @@ use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException; use TYPO3\CMS\Core\Context\LanguageAspect; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -99,7 +100,7 @@ protected function getNewsRecord(): array ->select('*') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)) ) ->executeQuery()->fetchAssociative(); diff --git a/Classes/Database/QueryGenerator.php b/Classes/Database/QueryGenerator.php index 75781dff9a..61557d24bf 100644 --- a/Classes/Database/QueryGenerator.php +++ b/Classes/Database/QueryGenerator.php @@ -11,6 +11,7 @@ namespace GeorgRinger\News\Database; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -48,7 +49,7 @@ public function getTreeList($id, $depth, $begin = 0): string $queryBuilder->select('uid') ->from('pages') ->where( - $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, Connection::PARAM_INT)), $queryBuilder->expr()->eq('sys_language_uid', 0) ) ->orderBy('uid'); diff --git a/Classes/Domain/Repository/AdministrationRepository.php b/Classes/Domain/Repository/AdministrationRepository.php index fa09783912..414a29ce5a 100644 --- a/Classes/Domain/Repository/AdministrationRepository.php +++ b/Classes/Domain/Repository/AdministrationRepository.php @@ -37,7 +37,7 @@ public function getTotalCounts(): array ->from('sys_category_record_mm') ->where($queryBuilder->expr()->like( 'tablenames', - $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR) )) ->executeQuery()->fetchOne(); diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index 1c75c8f6a1..f8d34ba4ae 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -9,11 +9,11 @@ namespace GeorgRinger\News\Domain\Repository; -use Doctrine\DBAL\Connection; use GeorgRinger\News\Domain\Model\Category; use GeorgRinger\News\Domain\Model\DemandInterface; use GeorgRinger\News\Service\CategoryService; use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -202,7 +202,7 @@ protected function overlayTranslatedCategoryIds(array &$idList): void ->select('l10n_parent', 'uid', 'sys_language_uid') ->from('sys_category') ->where( - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, Connection::PARAM_INT)), $queryBuilder->expr()->in('l10n_parent', $queryBuilder->createNamedParameter($idList, Connection::PARAM_INT_ARRAY)) ) ->executeQuery()->fetchAllAssociative(); diff --git a/Classes/Event/Listener/ModifyDatabaseQueryForContentEventListener.php b/Classes/Event/Listener/ModifyDatabaseQueryForContentEventListener.php index 438150b615..67f557ea35 100644 --- a/Classes/Event/Listener/ModifyDatabaseQueryForContentEventListener.php +++ b/Classes/Event/Listener/ModifyDatabaseQueryForContentEventListener.php @@ -13,6 +13,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForContentEvent; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; @@ -42,7 +43,7 @@ public function modify(ModifyDatabaseQueryForContentEvent $event): void // Only hide elements which are inline, allowing for standard // elements to show $event->getQueryBuilder()->andWhere( - $event->getQueryBuilder()->expr()->eq('tx_news_related_news', $event->getQueryBuilder()->createNamedParameter(0, \PDO::PARAM_INT)) + $event->getQueryBuilder()->expr()->eq('tx_news_related_news', $event->getQueryBuilder()->createNamedParameter(0, Connection::PARAM_INT)) ); if (self::$count === 0) { diff --git a/Classes/Event/Listener/ModifyDatabaseQueryForRecordListingEventListener.php b/Classes/Event/Listener/ModifyDatabaseQueryForRecordListingEventListener.php index 400545045f..5c1899630b 100644 --- a/Classes/Event/Listener/ModifyDatabaseQueryForRecordListingEventListener.php +++ b/Classes/Event/Listener/ModifyDatabaseQueryForRecordListingEventListener.php @@ -13,6 +13,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\Event\ModifyDatabaseQueryForRecordListingEvent; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; @@ -41,7 +42,7 @@ public function modify(ModifyDatabaseQueryForRecordListingEvent $event): void // Only hide elements which are inline, allowing for standard // elements to show $event->getQueryBuilder()->andWhere( - $event->getQueryBuilder()->expr()->eq('tx_news_related_news', $event->getQueryBuilder()->createNamedParameter(0, \PDO::PARAM_INT)) + $event->getQueryBuilder()->expr()->eq('tx_news_related_news', $event->getQueryBuilder()->createNamedParameter(0, Connection::PARAM_INT)) ); if (self::$count === 0) { diff --git a/Classes/Hooks/Backend/PageViewQueryHook.php b/Classes/Hooks/Backend/PageViewQueryHook.php index 657cc3b051..8f29dc455b 100644 --- a/Classes/Hooks/Backend/PageViewQueryHook.php +++ b/Classes/Hooks/Backend/PageViewQueryHook.php @@ -10,6 +10,7 @@ namespace GeorgRinger\News\Hooks\Backend; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Messaging\FlashMessage; @@ -57,7 +58,7 @@ public function modifyQuery( // Only hide elements which are inline, allowing for standard // elements to show $queryBuilder->andWhere( - $queryBuilder->expr()->eq('tx_news_related_news', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('tx_news_related_news', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)) ); if (self::$count === 0) { diff --git a/Classes/Seo/NewsAvailability.php b/Classes/Seo/NewsAvailability.php index dc4471e366..912c79332b 100644 --- a/Classes/Seo/NewsAvailability.php +++ b/Classes/Seo/NewsAvailability.php @@ -12,6 +12,7 @@ namespace GeorgRinger\News\Seo; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Routing\PageArguments; use TYPO3\CMS\Core\Site\Entity\SiteInterface; @@ -82,26 +83,26 @@ protected function getNewsRecord(int $newsId, int $language) if ($language === 0) { $where = [ $queryBuilder->expr()->or( - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, Connection::PARAM_INT)) ), - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)), ]; } else { $where = [ $queryBuilder->expr()->or( $queryBuilder->expr()->and( - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(-1, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)) ), $queryBuilder->expr()->and( - $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, Connection::PARAM_INT)) ), $queryBuilder->expr()->and( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($language, Connection::PARAM_INT)) ) ), ]; diff --git a/Classes/Seo/NewsXmlSitemapDataProvider.php b/Classes/Seo/NewsXmlSitemapDataProvider.php index fb1e98b38e..e33de7b5ef 100644 --- a/Classes/Seo/NewsXmlSitemapDataProvider.php +++ b/Classes/Seo/NewsXmlSitemapDataProvider.php @@ -235,9 +235,9 @@ protected function getSinglePidFromCategory(int $newsId): int $queryBuilder->expr()->eq('sys_category_record_mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid')) ) ->where( - $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), - $queryBuilder->expr()->gt('sys_category.single_pid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)), + $queryBuilder->expr()->gt('sys_category.single_pid', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)) ) ->setMaxResults(1) ->executeQuery()->fetchAssociative(); diff --git a/Classes/Service/AccessControlService.php b/Classes/Service/AccessControlService.php index 1260e36873..25492de0fe 100644 --- a/Classes/Service/AccessControlService.php +++ b/Classes/Service/AccessControlService.php @@ -10,6 +10,7 @@ namespace GeorgRinger\News\Service; use GeorgRinger\News\Domain\Model\Dto\EmConfiguration; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; @@ -102,9 +103,9 @@ public static function getCategoriesForNewsRecord($newsRecord): array $newsRecordCategoriesCount = $queryBuilder->count('*') ->from('sys_category_record_mm') ->where( - $queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($newsRecord['uid'], \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), - $queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR)) + $queryBuilder->expr()->eq('uid_foreign', $queryBuilder->createNamedParameter($newsRecord['uid'], Connection::PARAM_INT)), + $queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)), + $queryBuilder->expr()->eq('fieldname', $queryBuilder->createNamedParameter('categories', Connection::PARAM_STR)) ) ->executeQuery()->fetchOne(); if ($newsRecordCategoriesCount > 0) { @@ -141,9 +142,9 @@ public static function getCategoriesForNewsRecord($newsRecord): array $queryBuilder->expr()->eq('sys_category_record_mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid')) ) ->where( - $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), - $queryBuilder->expr()->eq('sys_category_record_mm.fieldname', $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR)), - $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsRecordUid, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)), + $queryBuilder->expr()->eq('sys_category_record_mm.fieldname', $queryBuilder->createNamedParameter('categories', Connection::PARAM_STR)), + $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsRecordUid, Connection::PARAM_INT)) ) ->executeQuery(); diff --git a/Classes/Service/CategoryService.php b/Classes/Service/CategoryService.php index 48698e2743..108f880ce1 100644 --- a/Classes/Service/CategoryService.php +++ b/Classes/Service/CategoryService.php @@ -137,8 +137,8 @@ public static function translateCategoryRecord($default, array $row = []): strin ->select('title') ->from('sys_category') ->where( - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($overlayLanguage, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($row['uid'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter($overlayLanguage, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($row['uid'], Connection::PARAM_INT)) ) ->setMaxResults(1) ->executeQuery()->fetchAssociative(); diff --git a/Classes/Service/LinkHandlerTargetPageService.php b/Classes/Service/LinkHandlerTargetPageService.php index 4735975466..44348a8826 100644 --- a/Classes/Service/LinkHandlerTargetPageService.php +++ b/Classes/Service/LinkHandlerTargetPageService.php @@ -11,6 +11,7 @@ namespace GeorgRinger\News\Service; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -61,9 +62,9 @@ protected function getSinglePidFromCategory(int $newsId): int $queryBuilder->expr()->eq('sys_category_record_mm.uid_local', $queryBuilder->quoteIdentifier('sys_category.uid')) ) ->where( - $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR)), - $queryBuilder->expr()->gt('sys_category.single_pid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsId, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('sys_category_record_mm.tablenames', $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR)), + $queryBuilder->expr()->gt('sys_category.single_pid', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('sys_category_record_mm.uid_foreign', $queryBuilder->createNamedParameter($newsId, Connection::PARAM_INT)) ) ->orderBy('sys_category_record_mm.sorting') ->setMaxResults(1) diff --git a/Classes/Service/SlugService.php b/Classes/Service/SlugService.php index eaa7ce941f..f47979d2ed 100644 --- a/Classes/Service/SlugService.php +++ b/Classes/Service/SlugService.php @@ -36,7 +36,7 @@ public function countOfSlugUpdates(): int ->from('tx_news_domain_model_news') ->where( $queryBuilder->expr()->or( - $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)), + $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', Connection::PARAM_STR)), $queryBuilder->expr()->isNull('path_segment') ) ) @@ -54,7 +54,7 @@ public function performUpdates(): array ->from('tx_news_domain_model_news') ->where( $queryBuilder->expr()->or( - $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)), + $queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', Connection::PARAM_STR)), $queryBuilder->expr()->isNull('path_segment') ) ) @@ -68,7 +68,7 @@ public function performUpdates(): array ->where( $queryBuilder->expr()->eq( 'uid', - $queryBuilder->createNamedParameter($record['uid'], \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($record['uid'], Connection::PARAM_INT) ) ) ->set('path_segment', $this->getUniqueValue($record['uid'], $record['sys_language_uid'], $slug)); @@ -119,13 +119,13 @@ protected function getUniqueCountStatement(int $uid, int $languageId, string $sl ->where( $queryBuilder->expr()->eq( 'path_segment', - $queryBuilder->createPositionalParameter($slug, \PDO::PARAM_STR) + $queryBuilder->createPositionalParameter($slug, Connection::PARAM_STR) ), $queryBuilder->expr()->eq( 'sys_language_uid', - $queryBuilder->createPositionalParameter($languageId, \PDO::PARAM_INT) + $queryBuilder->createPositionalParameter($languageId, Connection::PARAM_INT) ), - $queryBuilder->expr()->neq('uid', $queryBuilder->createPositionalParameter($uid, \PDO::PARAM_INT)) + $queryBuilder->expr()->neq('uid', $queryBuilder->createPositionalParameter($uid, Connection::PARAM_INT)) ); } @@ -160,7 +160,7 @@ public function countOfRealurlAliasMigrations(): int $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.path_segment', - $queryBuilder->createNamedParameter('', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('', Connection::PARAM_STR) ), $queryBuilder->expr()->isNull('tx_news_domain_model_news.path_segment') ), @@ -170,16 +170,16 @@ public function countOfRealurlAliasMigrations(): int ), $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.tablename', - $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR) ), $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.expire', - $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter(0, Connection::PARAM_INT) ), $queryBuilder->expr()->gte( 'tx_realurl_uniqalias.expire', - $queryBuilder->createNamedParameter($GLOBALS['ACCESS_TIME'], \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($GLOBALS['ACCESS_TIME'], Connection::PARAM_INT) ) ) ) @@ -238,7 +238,7 @@ public function performRealurlAliasMigration(): array $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_news_domain_model_news.path_segment', - $queryBuilder->createNamedParameter('', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('', Connection::PARAM_STR) ), $queryBuilder->expr()->isNull('tx_news_domain_model_news.path_segment') ), @@ -248,16 +248,16 @@ public function performRealurlAliasMigration(): array ), $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.tablename', - $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR) ), $queryBuilder->expr()->or( $queryBuilder->expr()->eq( 'tx_realurl_uniqalias.expire', - $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter(0, Connection::PARAM_INT) ), $queryBuilder->expr()->gte( 'tx_realurl_uniqalias.expire', - $queryBuilder->createNamedParameter($GLOBALS['ACCESS_TIME'], \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($GLOBALS['ACCESS_TIME'], Connection::PARAM_INT) ) ) ) @@ -272,7 +272,7 @@ public function performRealurlAliasMigration(): array ->where( $queryBuilder->expr()->eq( 'uid', - $queryBuilder->createNamedParameter($record['uid'], \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($record['uid'], Connection::PARAM_INT) ) ) ->set('path_segment', $this->getUniqueValue($record['uid'], $record['sys_language_uid'], $slug)); diff --git a/Classes/Updates/PopulateCategorySlugs.php b/Classes/Updates/PopulateCategorySlugs.php index 99908d260a..9b5ad6539f 100644 --- a/Classes/Updates/PopulateCategorySlugs.php +++ b/Classes/Updates/PopulateCategorySlugs.php @@ -11,6 +11,7 @@ namespace GeorgRinger\News\Updates; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; @@ -135,7 +136,7 @@ protected function populateSlugs(): void ->select('pid') ->from($this->table) ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], Connection::PARAM_INT)) )->executeQuery()->fetchAssociative(); $pid = (int)$liveVersion['pid']; } diff --git a/Classes/Updates/PopulateTagSlugs.php b/Classes/Updates/PopulateTagSlugs.php index 732368d69c..1615991783 100644 --- a/Classes/Updates/PopulateTagSlugs.php +++ b/Classes/Updates/PopulateTagSlugs.php @@ -11,6 +11,7 @@ namespace GeorgRinger\News\Updates; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory; @@ -135,7 +136,7 @@ protected function populateSlugs(): void ->select('pid') ->from($this->table) ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['t3ver_oid'], Connection::PARAM_INT)) )->executeQuery()->fetchAssociative(); $pid = (int)$liveVersion['pid']; } diff --git a/Classes/ViewHelpers/Category/CountViewHelper.php b/Classes/ViewHelpers/Category/CountViewHelper.php index abce0297bc..ab8204fe92 100644 --- a/Classes/ViewHelpers/Category/CountViewHelper.php +++ b/Classes/ViewHelpers/Category/CountViewHelper.php @@ -77,15 +77,15 @@ public static function renderStatic( $queryBuilder->expr()->and( $queryBuilder->expr()->eq( 'sys_category.uid', - $queryBuilder->createNamedParameter($categoryUid, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($categoryUid, Connection::PARAM_INT) ), $queryBuilder->expr()->eq( 'sys_category_record_mm.tablenames', - $queryBuilder->createNamedParameter('tx_news_domain_model_news', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('tx_news_domain_model_news', Connection::PARAM_STR) ), $queryBuilder->expr()->eq( 'sys_category_record_mm.fieldname', - $queryBuilder->createNamedParameter('categories', \PDO::PARAM_STR) + $queryBuilder->createNamedParameter('categories', Connection::PARAM_STR) ), $queryBuilder->expr()->in( 'tx_news_domain_model_news.sys_language_uid', diff --git a/Classes/ViewHelpers/SimplePrevNextViewHelper.php b/Classes/ViewHelpers/SimplePrevNextViewHelper.php index e936ab1a5c..07bebbbcd4 100644 --- a/Classes/ViewHelpers/SimplePrevNextViewHelper.php +++ b/Classes/ViewHelpers/SimplePrevNextViewHelper.php @@ -177,27 +177,27 @@ protected function getNeighbours(News $news, string $pidList, string $sortField) $queryBuilder = $connection->createQueryBuilder(); $extraWhere = [ - $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($news->getUid(), \PDO::PARAM_INT)), + $queryBuilder->expr()->neq('uid', $queryBuilder->createNamedParameter($news->getUid(), Connection::PARAM_INT)), ]; if ((bool)($this->arguments['includeInternalType'] ?? false) === false) { - $extraWhere[] = $queryBuilder->expr()->neq('type', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)); + $extraWhere[] = $queryBuilder->expr()->neq('type', $queryBuilder->createNamedParameter(1, Connection::PARAM_INT)); } if ((bool)($this->arguments['includeExternalType'] ?? false) === false) { - $extraWhere[] = $queryBuilder->expr()->neq('type', $queryBuilder->createNamedParameter(2, \PDO::PARAM_INT)); + $extraWhere[] = $queryBuilder->expr()->neq('type', $queryBuilder->createNamedParameter(2, Connection::PARAM_INT)); } $getter = 'get' . ucfirst($sortField) . ''; if ($news->$getter() instanceof \DateTime) { if ($label === 'prev') { - $extraWhere[] = $queryBuilder->expr()->lt($sortField, $queryBuilder->createNamedParameter($news->$getter()->getTimestamp(), \PDO::PARAM_INT)); + $extraWhere[] = $queryBuilder->expr()->lt($sortField, $queryBuilder->createNamedParameter($news->$getter()->getTimestamp(), Connection::PARAM_INT)); } else { - $extraWhere[] = $queryBuilder->expr()->gt($sortField, $queryBuilder->createNamedParameter($news->$getter()->getTimestamp(), \PDO::PARAM_INT)); + $extraWhere[] = $queryBuilder->expr()->gt($sortField, $queryBuilder->createNamedParameter($news->$getter()->getTimestamp(), Connection::PARAM_INT)); } } else { if ($label === 'prev') { - $extraWhere[] = $queryBuilder->expr()->lt($sortField, $queryBuilder->createNamedParameter($news->$getter(), \PDO::PARAM_STR)); + $extraWhere[] = $queryBuilder->expr()->lt($sortField, $queryBuilder->createNamedParameter($news->$getter(), Connection::PARAM_STR)); } else { - $extraWhere[] = $queryBuilder->expr()->gt($sortField, $queryBuilder->createNamedParameter($news->$getter(), \PDO::PARAM_STR)); + $extraWhere[] = $queryBuilder->expr()->gt($sortField, $queryBuilder->createNamedParameter($news->$getter(), Connection::PARAM_STR)); } } @@ -205,7 +205,7 @@ protected function getNeighbours(News $news, string $pidList, string $sortField) ->select('*') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)), $queryBuilder->expr()->in('pid', $queryBuilder->createNamedParameter(explode(',', $pidList), Connection::PARAM_INT_ARRAY)) ) ->andWhere(...$extraWhere) @@ -239,7 +239,7 @@ protected function getRawRecord(int $id): ?array ->select('*') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, Connection::PARAM_INT)) ) ->setMaxResults(1) ->executeQuery()->fetchAssociative(); diff --git a/Classes/ViewHelpers/Tag/CountViewHelper.php b/Classes/ViewHelpers/Tag/CountViewHelper.php index 750f26c857..e7d3895ed9 100644 --- a/Classes/ViewHelpers/Tag/CountViewHelper.php +++ b/Classes/ViewHelpers/Tag/CountViewHelper.php @@ -11,6 +11,7 @@ namespace GeorgRinger\News\ViewHelpers\Tag; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -68,7 +69,7 @@ public static function renderStatic( $queryBuilder->expr()->eq('tx_news_domain_model_tag.uid', $queryBuilder->quoteIdentifier('tx_news_domain_model_news_tag_mm.uid_foreign')) ) ->where( - $queryBuilder->expr()->eq('tx_news_domain_model_tag.uid', $queryBuilder->createNamedParameter($arguments['tagUid'], \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('tx_news_domain_model_tag.uid', $queryBuilder->createNamedParameter($arguments['tagUid'], Connection::PARAM_INT)) ) ->executeQuery()->fetchOne(); diff --git a/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php b/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php index 75a7cf4a9e..0bff6b9ae6 100644 --- a/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/SimplePrevNextViewHelperTest.php @@ -12,6 +12,7 @@ use DateTime; use GeorgRinger\News\Domain\Model\News; use GeorgRinger\News\ViewHelpers\SimplePrevNextViewHelper; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; @@ -106,7 +107,7 @@ protected function getRow(int $id) ->select('*') ->from('tx_news_domain_model_news') ->where( - $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)) + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, Connection::PARAM_INT)) ) ->setMaxResults(1) ->executeQuery()->fetchAssociative();