Skip to content
Snippets Groups Projects

Issue #3486188: [Regression] Clean up temporary files created by XML data...

1 file
+ 18
3
Compare changes
  • Side-by-side
  • Inline
@@ -87,6 +87,13 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
@@ -87,6 +87,13 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
*/
*/
protected bool $prefixedName = FALSE;
protected bool $prefixedName = FALSE;
 
/**
 
* Temporary file name of file that holds XML.
 
*
 
* @var string|null
 
*/
 
protected ?string $tempFileName;
 
/**
/**
* Constructs a new XML data parser.
* Constructs a new XML data parser.
*
*
@@ -201,8 +208,8 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
@@ -201,8 +208,8 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
// Fetch the data and save it to a temporary file.
// Fetch the data and save it to a temporary file.
$xml_data = $this->getDataFetcherPlugin()->getResponseContent($url);
$xml_data = $this->getDataFetcherPlugin()->getResponseContent($url);
$url = $this->fileSystem->tempnam('temporary://', 'file');
$this->tempFileName = $this->fileSystem->tempnam('temporary://', 'file');
if (file_put_contents($url, $xml_data) === FALSE) {
if (file_put_contents($this->tempFileName, $xml_data) === FALSE) {
throw new MigrateException('Unable to save temporary XML');
throw new MigrateException('Unable to save temporary XML');
}
}
@@ -212,7 +219,15 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
@@ -212,7 +219,15 @@ class Xml extends DataParserPluginBase implements ContainerFactoryPluginInterfac
// that occur from attempting to load the XML string into an object here.
// that occur from attempting to load the XML string into an object here.
libxml_clear_errors();
libxml_clear_errors();
return $this->reader->open($url, NULL, \LIBXML_NOWARNING);
return $this->reader->open($this->tempFileName, NULL, \LIBXML_NOWARNING);
 
}
 
 
protected function nextSource(): bool {
 
$valid_source = parent::nextSource();
 
if (isset($this->tempFileName) && file_exists($this->tempFileName)) {
 
unlink($this->tempFileName);
 
}
 
return $valid_source;
}
}
/**
/**
Loading