Skip to content

Commit 38d1cd3

Browse files
committed
tweak(Setup) tweak setup.xml simplexml error handling
1 parent 598fbd3 commit 38d1cd3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tine20/Setup/Controller.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,26 @@ public function getSetupXml($_applicationName, $_disableAppIfNotFound = false)
783783
throw new Setup_Exception_NotFound($setupXML . ' not found. If application got renamed or deleted, re-run setup.php.');
784784
}
785785
}
786-
786+
787+
// update tests have some wired issue here... valid xml cant be loaded...
788+
libxml_clear_errors();
787789
if (false === ($xml = simplexml_load_file($setupXML))) {
788790
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $setupXML
789791
. ' failed to load xml: ' . print_r(libxml_get_last_error(), true));
790-
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $setupXML
791-
. ' failed to load xml: "' . file_get_contents($setupXML) . '"');
792+
793+
$xmlString = file_get_contents($setupXML);
794+
if (str_starts_with($xmlString, '<?xml')) {
795+
libxml_clear_errors();
796+
if (false === ($xml = simplexml_load_string($setupXML))) {
797+
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $setupXML
798+
. ' failed to load xml: ' . print_r(libxml_get_last_error(), true));
799+
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $setupXML
800+
. ' failed to load xml: "' . $xmlString . '"');
801+
}
802+
} else {
803+
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $setupXML
804+
. ' failed to load xml: "' . $xmlString . '"');
805+
}
792806
}
793807

794808
return $xml;

0 commit comments

Comments
 (0)