From dba4855a49d62fcac3b47bf484166b4b140b5626 Mon Sep 17 00:00:00 2001 From: Jens Pausewang Date: Thu, 12 Dec 2024 12:28:47 +0100 Subject: [PATCH] Filter by active content elements first before deduplicating references This fixes a bug where the image credits for an image would not show up if there were two content elements on a page referencing the same image and the first content element being disabled. --- Classes/Domain/Repository/FileReferenceRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Repository/FileReferenceRepository.php b/Classes/Domain/Repository/FileReferenceRepository.php index 893f8cf..32233cf 100644 --- a/Classes/Domain/Repository/FileReferenceRepository.php +++ b/Classes/Domain/Repository/FileReferenceRepository.php @@ -50,8 +50,8 @@ public function getReferencesOnPage(int $pageId): array $event = new AfterImageReferencesLoadedEvent($result->toArray()); $this->eventDispatcher->dispatch($event); - $result = array_filter( - ArrayUtility::uniqueObjectsByProperty($event->getFileReferences(), 'uidLocal'), + $result = ArrayUtility::uniqueObjectsByProperty(array_filter( + $event->getFileReferences(), function (FileReference $reference) { $qb = $this->connectionPool->getQueryBuilderForTable($reference->getTablenames()); $query = $qb->from($reference->getTablenames()) @@ -66,7 +66,7 @@ function (FileReference $reference) { $rowCount = $query->executeQuery()->rowCount(); return $rowCount > 0; } - ); + ), 'uidLocal'); $event = new AfterImageReferencesDeduplicatedEvent($result); $this->eventDispatcher->dispatch($event);