Skip to content

Commit

Permalink
Filter by active content elements first before deduplicating references
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hackerman26 authored and sebkln committed Jan 24, 2025
1 parent 08df53a commit 644f4ee
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Classes/Domain/Repository/FileReferenceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -66,7 +66,7 @@ function (FileReference $reference) {
$rowCount = $query->executeQuery()->rowCount();
return $rowCount > 0;
}
);
), 'uidLocal');

$event = new AfterImageReferencesDeduplicatedEvent($result);
$this->eventDispatcher->dispatch($event);
Expand Down

0 comments on commit 644f4ee

Please sign in to comment.