Fix broken rss feed for specific category

Ease the setup, no need for a where, use native uidInList instead.
This commit is contained in:
Daniel Siepmann 2024-02-09 09:25:03 +01:00
parent 6d10bdb4ef
commit 11f09d9f08

View file

@ -48,7 +48,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface
$contentObjectRenderer, $contentObjectRenderer,
$contentObjectConfiguration, $contentObjectConfiguration,
array_merge($processorConfiguration, [ array_merge($processorConfiguration, [
'where' => 'AND no_index = 0' . $this->getAdditionalWhere($contentObjectRenderer->getRequest()), 'uidInList' => $this->getPageUids($contentObjectRenderer->getRequest()),
]), ]),
$processedData $processedData
); );
@ -64,21 +64,14 @@ final class BlogPostsDataProvider implements DataProcessorInterface
return $processedData; return $processedData;
} }
private function getAdditionalWhere(ServerRequestInterface $request): string private function getPageUids(ServerRequestInterface $request): string
{ {
$categoryUid = (int) ($request->getQueryParams()['category_uid'] ?? 0); $categoryUid = (int) ($request->getQueryParams()['category_uid'] ?? 0);
if ($categoryUid === 0) { if ($categoryUid === 0) {
return ''; return '';
} }
$pageUids = $this->getPageUidsWithRelationToCategory($categoryUid); return implode(',', $this->getPageUidsWithRelationToCategory($categoryUid));
$where = $this->createAdditionalWhereForPageUids($pageUids);
if ($where !== '') {
return '';
}
return ' ' . $where;
} }
private function getPageUidsWithRelationToCategory(int $categoryUid): array private function getPageUidsWithRelationToCategory(int $categoryUid): array
@ -116,11 +109,6 @@ final class BlogPostsDataProvider implements DataProcessorInterface
}, $queryBuilder->executeQuery()->fetchAllAssociative()); }, $queryBuilder->executeQuery()->fetchAllAssociative());
} }
private function createAdditionalWhereForPageUids(array $pageUids): string
{
return ' AND uid IN(' . implode(',', $pageUids) . ')';
}
private function getContent( private function getContent(
ContentObjectRenderer $contentObjectRenderer, ContentObjectRenderer $contentObjectRenderer,
int $pageUid int $pageUid