From ff3f66b80ea931c1f8743c0bcce6d19cb8e4c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 10 Jul 2020 12:15:36 +0200 Subject: [PATCH 1/3] Update ddev config --- public/typo3conf/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/public/typo3conf/.gitignore b/public/typo3conf/.gitignore index 2f83a7c7..0efaa766 100644 --- a/public/typo3conf/.gitignore +++ b/public/typo3conf/.gitignore @@ -1,5 +1,6 @@ #ddev-generated: Automatically generated ddev .gitignore. # You can remove the above line if you want to edit and maintain this file yourself. +/.gitignore /AdditionalConfiguration.php /drushrc.php From ca2dd2ed781816cb4481654eee9d0b2748642bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 10 Jul 2020 12:15:46 +0200 Subject: [PATCH 2/3] Update project dependencies --- composer.lock | 76 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/composer.lock b/composer.lock index 54ae4f7b..605093dd 100644 --- a/composer.lock +++ b/composer.lock @@ -169,16 +169,16 @@ }, { "name": "doctrine/cache", - "version": "1.10.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "35a4a70cd94e09e2259dfae7488afc6b474ecbd3" + "reference": "13e3381b25847283a91948d04640543941309727" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/35a4a70cd94e09e2259dfae7488afc6b474ecbd3", - "reference": "35a4a70cd94e09e2259dfae7488afc6b474ecbd3", + "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727", + "reference": "13e3381b25847283a91948d04640543941309727", "shasum": "" }, "require": { @@ -261,7 +261,7 @@ "type": "tidelift" } ], - "time": "2020-05-27T16:24:54+00:00" + "time": "2020-07-07T18:54:01+00:00" }, { "name": "doctrine/dbal", @@ -1516,16 +1516,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.5.0", + "version": "v4.6.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463" + "reference": "c346bbfafe2ff60680258b631afb730d186ed864" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/53c2753d756f5adb586dca79c2ec0e2654dd9463", - "reference": "53c2753d756f5adb586dca79c2ec0e2654dd9463", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c346bbfafe2ff60680258b631afb730d186ed864", + "reference": "c346bbfafe2ff60680258b631afb730d186ed864", "shasum": "" }, "require": { @@ -1564,7 +1564,7 @@ "parser", "php" ], - "time": "2020-06-03T07:24:19+00:00" + "time": "2020-07-02T17:12:47+00:00" }, { "name": "pixelant/pxa-social-feed", @@ -2294,16 +2294,16 @@ }, { "name": "symfony/cache-contracts", - "version": "v2.1.2", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/symfony/cache-contracts.git", - "reference": "87c92f62c494626598e9148208aaa6d1716b8e3c" + "reference": "9771a09d2e6b84ecb8c9f0a7dbc72ee92aeba009" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/87c92f62c494626598e9148208aaa6d1716b8e3c", - "reference": "87c92f62c494626598e9148208aaa6d1716b8e3c", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/9771a09d2e6b84ecb8c9f0a7dbc72ee92aeba009", + "reference": "9771a09d2e6b84ecb8c9f0a7dbc72ee92aeba009", "shasum": "" }, "require": { @@ -2317,6 +2317,10 @@ "extra": { "branch-alias": { "dev-master": "2.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2362,7 +2366,7 @@ "type": "tidelift" } ], - "time": "2020-05-20T17:43:50+00:00" + "time": "2020-07-06T13:23:11+00:00" }, { "name": "symfony/console", @@ -2457,16 +2461,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v2.1.2", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337" + "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", - "reference": "dd99cb3a0aff6cadd2a8d7d7ed72c2161e218337", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5e20b83385a77593259c9f8beb2c43cd03b2ac14", + "reference": "5e20b83385a77593259c9f8beb2c43cd03b2ac14", "shasum": "" }, "require": { @@ -2476,6 +2480,10 @@ "extra": { "branch-alias": { "dev-master": "2.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2513,7 +2521,7 @@ "type": "tidelift" } ], - "time": "2020-05-27T08:34:37+00:00" + "time": "2020-06-06T08:49:21+00:00" }, { "name": "symfony/expression-language", @@ -2727,16 +2735,16 @@ }, { "name": "symfony/http-client-contracts", - "version": "v2.1.2", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/symfony/http-client-contracts.git", - "reference": "f8bed25edc964d015bcd87f1fec5734963931910" + "reference": "cd88921e9add61f2064c9c6b30de4f589db42962" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/f8bed25edc964d015bcd87f1fec5734963931910", - "reference": "f8bed25edc964d015bcd87f1fec5734963931910", + "url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/cd88921e9add61f2064c9c6b30de4f589db42962", + "reference": "cd88921e9add61f2064c9c6b30de4f589db42962", "shasum": "" }, "require": { @@ -2749,6 +2757,10 @@ "extra": { "branch-alias": { "dev-master": "2.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -2794,7 +2806,7 @@ "type": "tidelift" } ], - "time": "2020-05-25T17:37:45+00:00" + "time": "2020-07-06T13:23:11+00:00" }, { "name": "symfony/http-foundation", @@ -4127,16 +4139,16 @@ }, { "name": "symfony/service-contracts", - "version": "v2.1.2", + "version": "v2.1.3", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b" + "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/66a8f0957a3ca54e4f724e49028ab19d75a8918b", - "reference": "66a8f0957a3ca54e4f724e49028ab19d75a8918b", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/58c7475e5457c5492c26cc740cc0ad7464be9442", + "reference": "58c7475e5457c5492c26cc740cc0ad7464be9442", "shasum": "" }, "require": { @@ -4150,6 +4162,10 @@ "extra": { "branch-alias": { "dev-master": "2.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4195,7 +4211,7 @@ "type": "tidelift" } ], - "time": "2020-05-20T17:43:50+00:00" + "time": "2020-07-06T13:23:11+00:00" }, { "name": "symfony/string", From 900aa785c13dd485ad9ecd153c9ab66cc661ea16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 10 Jul 2020 15:39:28 +0200 Subject: [PATCH 3/3] Adjust date import to changes in xml upload --- .../Classes/Command/DateCommandController.php | 14 +++--- .../Classes/Service/DateImportService.php | 43 +++++++++++++------ .../Classes/Task/ImportDatesTask.php | 8 ---- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Command/DateCommandController.php b/public/typo3conf/ext/ep_products/Classes/Command/DateCommandController.php index aae1efdb..89b930db 100644 --- a/public/typo3conf/ext/ep_products/Classes/Command/DateCommandController.php +++ b/public/typo3conf/ext/ep_products/Classes/Command/DateCommandController.php @@ -80,15 +80,11 @@ class DateCommandController extends Command public function execute(InputInterface $input, OutputInterface $output) { $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport'); - if ($this->dateImportService->checkActiveUpload($path)) { - $output->writeln('Import cancelled due to active file upload.'); - } else { - $count = $this->dateImportService->import($path); - $output->writeln(sprintf('%d rows imported.', $count )); - $settings = $this->getSettings(); - $resellerPageUid = $settings['resellerExportPageUid']; - $this->cacheService->clearPageCache($resellerPageUid); - } + $count = $this->dateImportService->import($path); + $output->writeln(sprintf('%d rows imported.', $count )); + $settings = $this->getSettings(); + $resellerPageUid = $settings['resellerExportPageUid']; + $this->cacheService->clearPageCache($resellerPageUid); } /** diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php index 1978cbd3..0f99a3b9 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php @@ -125,7 +125,7 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface $this->importPickups(); $this->createTempTables(); $this->logger->info('starting product import'); - $dateCount = $this->parseXmlFilesInFolder($path); + $dateCount = $this->parseXmlFilesForProducts($path); $this->clearTables(); $this->copyTables(); $this->clearTempTables(); @@ -144,20 +144,30 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface return count(glob($tempFile)) > 0; } - /** - * @param string $path - * @return int - */ - public function parseXmlFilesInFolder($path) + public function parseXmlFilesForProducts($path) { - $dateCount = 0; - $folder = opendir($path); - while (($fileName = readdir($folder)) !== false) { - if (strpos($fileName, 'Ziel') === 0) { - $filePath = $path . '/' . $fileName; - $dateCount += $this->parseProductXmlFile($filePath); - } + $xmlPath = sprintf('%s/Produkte.xml', $path); + + if (!file_exists($xmlPath)) { + $this->logger->error('product list xml not found'); + return 0; } + + libxml_use_internal_errors(true); + /** @var \SimpleXMLElement $xmlData */ + if (!$xmlData = simplexml_load_string(file_get_contents($xmlPath))) { + libxml_clear_errors(); + return 0; + } + + $dateCount = 0; + + foreach ($xmlData->produkte[0]->children() as $xmlProdukt) { + $busProId = (int)$xmlProdukt->attributes()['id']; + $xmlFile = sprintf('%s/Ziel_%d.xml', $path, $busProId); + $dateCount += $this->parseProductXmlFile($xmlFile); + } + return $dateCount; } @@ -167,7 +177,12 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface */ public function parseProductXmlFile($file) { - libxml_use_internal_errors (true); + if (!file_exists($file)) { + $this->logger->error('product xml not found', ['file' => $file]); + return 0; + } + + libxml_use_internal_errors(true); /** @var \SimpleXMLElement $xmlData */ if (!$xmlData = simplexml_load_string(file_get_contents($file))) { libxml_clear_errors(); diff --git a/public/typo3conf/ext/ep_products/Classes/Task/ImportDatesTask.php b/public/typo3conf/ext/ep_products/Classes/Task/ImportDatesTask.php index 4012193b..ee2c21c2 100644 --- a/public/typo3conf/ext/ep_products/Classes/Task/ImportDatesTask.php +++ b/public/typo3conf/ext/ep_products/Classes/Task/ImportDatesTask.php @@ -28,7 +28,6 @@ namespace EP\EpProducts\Task; ***************************************************************/ use EP\EpProducts\Service\DateImportService; -use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Scheduler\Task\AbstractTask; @@ -42,13 +41,6 @@ class ImportDatesTask extends AbstractTask /** @var \EP\EpProducts\Service\DateImportService $importService */ $importService = $objectManager->get(DateImportService::class); $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport'); - if ($importService->checkActiveUpload($path)) { - $message = GeneralUtility::makeInstance(FlashMessage::class, 'Import aborted due to active file upload', '', FlashMessage::WARNING); - $flashMessageService = $objectManager->get(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); - $messageQueue = $flashMessageService->getMessageQueueByIdentifier(); - $messageQueue->addMessage($message); - return false; - } $importService->import($path); return true; }