Commit 5c78eec8 authored by Dave Reid's avatar Dave Reid

Added additional failure checks for startDocument() return value, and empty...

Added additional failure checks for startDocument() return value, and empty filesize() on endDocument().
parent 1e721090
......@@ -45,11 +45,15 @@ class XMLSitemapWriter extends XMLWriter {
public function startDocument($version = '1.0', $encoding = 'UTF-8', $standalone = NULL) {
$this->setIndent(FALSE);
parent::startDocument($version, $encoding);
$result = parent::startDocument($version, $encoding);
if (!$result) {
throw new XMLSitemapGenerationException(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
}
if (variable_get('xmlsitemap_xsl', 1)) {
$this->writeXSL();
}
$this->startElement($this->rootElement, TRUE);
return $result;
}
/**
......@@ -148,6 +152,10 @@ class XMLSitemapWriter extends XMLWriter {
// file_put_contents($file_gz, gzencode(file_get_contents($file), 9));
//}
if (!filesize($this->uri)) {
throw new XMLSitemapGenerationException(t('Generated @file resulted in an empty file.', array('@file' => $this->uri)));
}
return $return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment