From 99ed212ffc1ede94d3ce2be9ce7674611ca7c74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 10 Jul 2025 14:40:49 +0200 Subject: [PATCH] fix: make bpn import resilient to missing data --- src/Command/BpnImportCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Command/BpnImportCommand.php b/src/Command/BpnImportCommand.php index a7bf608..769ffcc 100644 --- a/src/Command/BpnImportCommand.php +++ b/src/Command/BpnImportCommand.php @@ -83,7 +83,11 @@ class BpnImportCommand extends Command foreach ($destinationXml->xpath('zustiege/zustieg') as $pickupXml) { $pickupBusProId = (int) $pickupXml->attributes()['idbuspro']; if ($pickupBusProId) { - $pickup = $this->pickupDataProvider->get($pickupBusProId); + if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) { + $io->warning('Pickup with busProId '.$pickupBusProId.' not found'); + continue; + } + $datePickups[] = [ 'busProId' => $pickupBusProId, 'city' => $pickup->getCity(), @@ -96,7 +100,10 @@ class BpnImportCommand extends Command // Iterate over all hotel entries foreach ($destinationXml->xpath('hotel') as $hotelXml) { $hotelBusProId = (int) $hotelXml->attributes()['idbuspro']; - $hotel = $this->hotelDataProvider->get($hotelBusProId); + if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) { + $io->warning('Hotel with busProId '.$hotelBusProId.' not found'); + continue; + } // Finally update or store collected data if ($id = $this->connection->fetchOne('SELECT id FROM destination WHERE bus_pro_id=? AND hotel_bus_pro_id=?', [$busProId, $hotelBusProId])) {