Skip to content
Snippets Groups Projects
Commit 8b68f193 authored by Brian Osborne's avatar Brian Osborne Committed by Mike Ryan
Browse files

Issue #2860788 by bkosborne: XML parser should clear XML error buffer before processing XML data

parent 586c6177
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,12 @@ class SimpleXml extends DataParserPluginBase { ...@@ -38,6 +38,12 @@ class SimpleXml extends DataParserPluginBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function openSourceUrl($url) { protected function openSourceUrl($url) {
// Clear XML error buffer. Other Drupal code that executed during the
// migration may have polluted the error buffer and could create false
// positives in our error check below. We are only concerned with errors
// that occur from attempting to load the XML string into an object here.
libxml_clear_errors();
$xml_data = $this->getDataFetcherPlugin()->getResponseContent($url); $xml_data = $this->getDataFetcherPlugin()->getResponseContent($url);
$xml = simplexml_load_string($xml_data); $xml = simplexml_load_string($xml_data);
$this->registerNamespaces($xml); $this->registerNamespaces($xml);
......
...@@ -174,6 +174,13 @@ class Xml extends DataParserPluginBase { ...@@ -174,6 +174,13 @@ class Xml extends DataParserPluginBase {
protected function openSourceUrl($url) { protected function openSourceUrl($url) {
// (Re)open the provided URL. // (Re)open the provided URL.
$this->reader->close(); $this->reader->close();
// Clear XML error buffer. Other Drupal code that executed during the
// migration may have polluted the error buffer and could create false
// positives in our error check below. We are only concerned with errors
// that occur from attempting to load the XML string into an object here.
libxml_clear_errors();
return $this->reader->open($url, NULL, \LIBXML_NOWARNING); return $this->reader->open($url, NULL, \LIBXML_NOWARNING);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment