@@ -330,7 +330,11 @@ public function read_XMP_array_from_text($xmltext)
330330 if (xml_parser_set_option ($ xml_parser , XML_OPTION_SKIP_WHITE , 0 ) == false )
331331 {
332332 // Error setting case folding - destroy the parser and return
333- xml_parser_free ($ xml_parser );
333+ if (PHP_VERSION_ID < 80000 ) { // xml_parser_free does nothing after PHP8 and give deprecation warnings in PHP8.5
334+ xml_parser_free ($ xml_parser );
335+ } else {
336+ unset($ xml_parser );
337+ }
334338 return false ;
335339 }
336340
@@ -340,20 +344,32 @@ public function read_XMP_array_from_text($xmltext)
340344 if (xml_parser_set_option ($ xml_parser , XML_OPTION_CASE_FOLDING , 0 ) == false )
341345 {
342346 // Error setting case folding - destroy the parser and return
343- xml_parser_free ($ xml_parser );
347+ if (PHP_VERSION_ID < 80000 ) { // xml_parser_free does nothing after PHP8 and give deprecation warnings in PHP8.5
348+ xml_parser_free ($ xml_parser );
349+ } else {
350+ unset($ xml_parser );
351+ }
344352 return false ;
345353 }
346354
347355 // Parse the XML text into a array structure
348356 if (xml_parse_into_struct ($ xml_parser , $ xmltext , $ values , $ tags ) == 0 )
349357 {
350358 // Error Parsing XML - destroy the parser and return
351- xml_parser_free ($ xml_parser );
359+ if (PHP_VERSION_ID < 80000 ) { // xml_parser_free does nothing after PHP8 and give deprecation warnings in PHP8.5
360+ xml_parser_free ($ xml_parser );
361+ } else {
362+ unset($ xml_parser );
363+ }
352364 return false ;
353365 }
354366
355367 // Destroy the xml parser
356- xml_parser_free ($ xml_parser );
368+ if (PHP_VERSION_ID < 80000 ) { // xml_parser_free does nothing after PHP8 and give deprecation warnings in PHP8.5
369+ xml_parser_free ($ xml_parser );
370+ } else {
371+ unset($ xml_parser );
372+ }
357373
358374 // Clear the output array
359375 $ xmp_array = array ();
0 commit comments