fix: hotels without a category no longer break product teasers

29 hotels have category 0, which has no label. The product teasers looked
the label up unguarded, an "Undefined array key 0" warning: a 500 in DDEV
(warnings are exceptions there), a logged warning in production. The
teaser and the hotel serializer now use null for an unknown category, as
SearchResultService and HotelDataService already do; TYPO3 10 ended up
with null as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-10-22 15:15:04 +02:00
1 parent ca2fdc1e13
commit b5637ba86e
2 files changed
+2 -2

No files matched your search

@@ -44,7 +44,7 @@ class Hotel
$hotel['@id'] = $entity->getUid();
$hotel['@code'] = $entity->getCode();
$hotel['name'] = $entity->getName();
$hotel['category'] = \EP\EpProducts\Domain\Model\Hotel::$categoryLabels[$entity->getCategory()];
$hotel['category'] = \EP\EpProducts\Domain\Model\Hotel::$categoryLabels[$entity->getCategory()] ?? null;
$hotel['type'] = \EP\EpProducts\Domain\Model\Hotel::$typeLabels[$entity->getType()];
$hotel['description'] = SerializationUtility::sanitizeText($entity->getDescription());
$hotel['roomtypes'] = SerializationUtility::sanitizeText($entity->getRoomTypes());
@@ -156,7 +156,7 @@ class ProductDataService implements SingletonInterface
}
if (!array_key_exists($row['hotelCategory'], $teaser['hotelCategories'])) {
$teaser['hotelCategories'][$row['hotelCategory']] = Hotel::$categoryLabels[$row['hotelCategory']];
$teaser['hotelCategories'][$row['hotelCategory']] = Hotel::$categoryLabels[$row['hotelCategory']] ?? null;
ksort($teaser['hotelCategories']);
}
}