Commit fc45a5c7 authored by Dave Reid's avatar Dave Reid

Issue #920062 by Kristen Pol, eriksen.costa, alveoten, Dave Reid: Fixed...

Issue #920062 by Kristen Pol, eriksen.costa, alveoten, Dave Reid: Fixed XMLWriter::openUri() needs a real path and not a stream wrapper URI. Fixed exceptions should be thrown during generation errors.
parent c55eebdf
......@@ -111,7 +111,7 @@ function xmlsitemap_requirements($phase) {
$generated_ago = REQUEST_TIME - $generated_last;
$requirements['xmlsitemap_generated'] = array(
'title' => $t('XML sitemap'),
'value' => $generated_last ? $t('Last generated on !date (!interval ago).', array('!date' => format_date($generated_last, 'small'), '!interval' => format_interval($generated_ago))) : $t('Cached files have not been generated yet.'),
'value' => $generated_last ? $t('Last attempted generation on !date (!interval ago).', array('!date' => format_date($generated_last, 'small'), '!interval' => format_interval($generated_ago))) : $t('Cached files have not been generated yet.'),
'severity' => REQUIREMENT_OK,
);
if (variable_get('xmlsitemap_rebuild_needed', FALSE) && _xmlsitemap_rebuild_form_access()) {
......@@ -119,7 +119,11 @@ function xmlsitemap_requirements($phase) {
$requirements['xmlsitemap_generated']['description'] = $t('The XML sitemap data is out of sync and needs to be <a href="@link-rebuild">completely rebuilt<a>.', array('@link-rebuild' => url('admin/config/search/xmlsitemap/rebuild')));
}
elseif (variable_get('xmlsitemap_regenerate_needed', FALSE)) {
if ($generated_ago >= variable_get('cron_threshold_error', 1209600)) {
if ($max_filesize == 0) {
// A maximum sitemap file size of 0 indicates an error in generation.
$requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
}
elseif ($generated_ago >= variable_get('cron_threshold_error', 1209600)) {
$requirements['xmlsitemap_generated']['severity'] = REQUIREMENT_ERROR;
}
elseif ($generated_ago >= variable_get('cron_threshold_warning', 172800)) {
......
......@@ -5,6 +5,10 @@
* XML sitemap integration functions for xmlsitemap.module.
*/
class XMLSitemapException extends Exception {}
class XMLSitemapGenerationException extends XMLSitemapException {}
/**
* Extended class for writing XML sitemap files.
*/
......@@ -33,9 +37,9 @@ class XMLSitemapWriter extends XMLWriter {
}
public function openUri($uri) {
$return = parent::openUri($uri);
$return = parent::openUri(drupal_realpath($uri));
if (!$return) {
trigger_error(t('Could not open file @file for writing.', array('@file' => $uri)));
throw new XMLSitemapGenerationException(t('Could not open file @file for writing.', array('@file' => $uri)));
}
return $return;
}
......@@ -150,8 +154,7 @@ class XMLSitemapWriter extends XMLWriter {
$return = parent::endDocument();
if (!$this->getStatus()) {
trigger_error(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
return FALSE;
throw new XMLSitemapGenerationException(t('Unknown error occurred while writing to file @file.', array('@file' => $this->uri)));
}
//if (xmlsitemap_var('gz')) {
......
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