Skip to content

Commit

Permalink
Add ID/URL of entity with broken opening hours
Browse files Browse the repository at this point in the history
This should ease debugging and allow users to fix broken data.

Relates: #11565
  • Loading branch information
d-s-codappix committed Jan 13, 2025
1 parent 35aa08d commit bd93524
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Classes/Domain/Import/Typo3Converter/GeneralConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private function buildDataArrayFromEntity(

'parking_facility_near_by' => $entity instanceof Base ? implode(',', $this->getParkingFacilitiesNearByUids($entity)) : '',

'opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getOpeningHoursSpecification()) : '',
'special_opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getSpecialOpeningHoursSpecification()) : '',
'opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getOpeningHoursSpecification(), $entity) : '',
'special_opening_hours' => $entity instanceof Place ? $this->getOpeningHours($entity->getSpecialOpeningHoursSpecification(), $entity) : '',
'address' => $entity instanceof Place ? $this->getAddress($entity) : '',
'url' => $entity->getUrls()[0] ?? '',
'offers' => $entity instanceof Place ? $this->getOffers($entity) : '',
Expand Down Expand Up @@ -374,7 +374,7 @@ private function getSingleMedia(
/**
* @param OpeningHour[] $openingHours
*/
private function getOpeningHours(array $openingHours): string
private function getOpeningHours(array $openingHours, Minimum $entity): string
{
$data = [];

Expand All @@ -388,8 +388,9 @@ private function getOpeningHours(array $openingHours): string
'daysOfWeek' => $openingHour->getDaysOfWeek(),
]);
} catch (InvalidDataException $e) {
$this->logger->error('Could not import opening hour due to type error: {errorMessage}', [
$this->logger->error('Could not import opening hour of entity "{entityId}" due to type error: {errorMessage}', [
'errorMessage' => $e->getMessage(),
'entityId' => $entity->getId(),
'openingHour' => var_export($openingHour, true),
]);
continue;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function importsWithBrokenOpeningHour(): void
$loggedErrors = file_get_contents($this->getErrorLogFile());
self::assertIsString($loggedErrors);
self::assertStringContainsString(
'Could not import opening hour due to type error: Opens was empty for opening hour.',
'Could not import opening hour of entity "https://thuecat.org/resources/attraction-with-broken-opening-hour" due to type error: Opens was empty for opening hour.',
$loggedErrors
);
self::assertStringContainsString('\'closes\' => NULL,', $loggedErrors);
Expand Down

0 comments on commit bd93524

Please sign in to comment.