Skip to content

Commit

Permalink
Update ZugferdProfileResolver.php
Browse files Browse the repository at this point in the history
Fixes #133

The new version of php_zugferd makes use of libxml_get_last_error() in order to verify that SimpleXMLElement() works.

However, if the user code (the code that calls php_zugferd) had accidentally raised an libxml error, then the error status will be preserved until php_zugferd calls libxml_get_last_error(). In other words: The user code had an error, completely unrelated to ZUGFeRD, and ZUGFeRD raises an error telling that the XML is wrong, which is not true.

This PR fixes the issue by making sure that the libxml error storage is clean before checking the SimpleXML result.
  • Loading branch information
danielmarschall authored Oct 4, 2024
1 parent 2381ea9 commit ef1bb65
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ZugferdProfileResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static function resolve(string $xmlContent): array
$prevUseInternalErrors = \libxml_use_internal_errors(true);

try {
libxml_clear_errors();
$xmldocument = new SimpleXMLElement($xmlContent);
$typeelement = $xmldocument->xpath('/rsm:CrossIndustryInvoice/rsm:ExchangedDocumentContext/ram:GuidelineSpecifiedDocumentContextParameter/ram:ID');
if (libxml_get_last_error()) {
Expand Down

0 comments on commit ef1bb65

Please sign in to comment.