From 856dbe81d81c27ac06d4729e74508e2d6e805c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Sat, 28 Aug 2021 09:59:38 +0200 Subject: [PATCH] Improve failure tolerance of contingent import service --- .../Classes/Service/ContingentImportService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php index be19c903..36317548 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php @@ -143,6 +143,9 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac public function loadXmlFile($file): ?\SimpleXMLElement { libxml_use_internal_errors (true); + if (!file_exists($file)) { + return null; + } /** @var \SimpleXMLElement $xmlData */ if (!$xmlData = simplexml_load_string(file_get_contents($file))) { libxml_clear_errors(); @@ -210,7 +213,9 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac if ($xmlContingent->idbuspro_kontingent_aus) { $linkedProductId = (int)$xmlContingent->idbuspro_kontingent_aus; $path = GeneralUtility::getFileAbsFileName(self::XML_PATH); - $xmlContingent = $this->loadXmlFile(sprintf('%s/HotelZimmer_%d.xml', $path, $linkedProductId)); + if (null === $xmlContingent = $this->loadXmlFile(sprintf('%s/HotelZimmer_%d.xml', $path, $linkedProductId))) { + return 0; + } } if (empty($xmlContingent->kapazitaeten)) {