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