Avoid errors caused by corrupted xml files

This commit is contained in:
Björn Fromme
2019-07-28 13:18:07 +02:00
parent 5cd6226a5b
commit c78dc5db32
2 changed files with 12 additions and 4 deletions
@@ -121,7 +121,7 @@ class ContingentImportService implements SingletonInterface
{
libxml_use_internal_errors (true);
/** @var \SimpleXMLElement $xmlData */
if (!$xmlData = simplexml_load_file($file)) {
if (!$xmlData = simplexml_load_string(file_get_contents($file))) {
libxml_clear_errors();
return 0;
}
@@ -171,8 +171,12 @@ class DateImportService implements SingletonInterface
*/
public function parseProductXmlFile($file)
{
libxml_use_internal_errors (true);
/** @var \SimpleXMLElement $xmlData */
$xmlData = simplexml_load_file($file);
if (!$xmlData = simplexml_load_string(file_get_contents($file))) {
libxml_clear_errors();
return 0;
}
if ($xmlData->reise[0] === null) {
return 0;
@@ -798,14 +802,18 @@ class DateImportService implements SingletonInterface
if (!array_key_exists($key, $list)) {
$list[$key] = [];
}
$list[$key] = array_merge($list[$key], $section);
$list[$key] += $section;
}
}
protected function importPickups()
{
libxml_use_internal_errors (true);
$path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport/zustiege.xml');
$xmlData = simplexml_load_file($path);
if (!$xmlData = simplexml_load_string(file_get_contents($path))) {
libxml_clear_errors();
return;
}
foreach ($xmlData->zustieg as $entry)
{