diff --git a/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php b/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php index 9224bfc8..9de39d66 100644 --- a/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php +++ b/Classes/DataProcessing/RootSiteProcessing/SiteProvider.php @@ -12,7 +12,6 @@ namespace FriendsOfTYPO3\Headless\DataProcessing\RootSiteProcessing; use Doctrine\DBAL\Driver\Exception; -use Doctrine\DBAL\Driver\Result; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Site\Entity\Site; @@ -149,7 +148,7 @@ private function filterSites(array $allowedSites = []): array foreach ($allSites as $site) { if (in_array($site->getRootPageId(), $allowedSites, true) && - $site->getConfiguration()['headless'] ?? false) { + $site->getConfiguration()['headless'] ?? false) { $sites[] = $site; } } @@ -166,18 +165,15 @@ private function fetchAvailableRootSitesByPid(int $pid): array { $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages'); - $stmt = $queryBuilder + $pagesData = $queryBuilder ->select('uid') ->from('pages') - ->where('is_siteroot = 1') - ->andWhere('hidden = 0') - ->andWhere('deleted = 0')->andWhere('pid = ' . $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT))->executeQuery(); - - $pagesData = []; - - if ($stmt instanceof Result) { - $pagesData = $stmt->fetchAllAssociative(); - } + ->andWhere( + $queryBuilder->expr()->eq('is_siteroot', $queryBuilder->createNamedParameter(1, Connection::PARAM_INT)), + $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, Connection::PARAM_INT)), + ) + ->executeQuery() + ->fetchAllAssociative(); return array_map(static function (array $item): int { return (int)$item['uid']; @@ -206,14 +202,17 @@ private function fetchPageData(array $sites, array $config = []): array $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages'); - $pagesData = []; - $stmt = $queryBuilder + $pagesData = $queryBuilder ->select(...$columns) - ->from('pages')->where('uid IN (' . $queryBuilder->createNamedParameter($rootPagesId, Connection::PARAM_INT_ARRAY) . ')')->executeQuery(); - - if ($stmt instanceof Result) { - $pagesData = $stmt->fetchAllAssociative(); - } + ->from('pages') + ->where( + $queryBuilder->expr()->in( + 'uid', + $queryBuilder->createNamedParameter($rootPagesId, Connection::PARAM_INT_ARRAY) + ) + ) + ->executeQuery() + ->fetchAllAssociative(); $pages = [];