summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2013-11-29 21:28:56 +0000
committerGreg Roach <fisharebest@gmail.com>2013-11-29 21:28:56 +0000
commit938cf28f38ea24f59c60e45eacd92d67c4c307a5 (patch)
treea90f096e386e776d296027006902886128e362fd
parent8392459abeede6ef845d07266d43c0ff7f82cef2 (diff)
downloadwebtrees-938cf28f38ea24f59c60e45eacd92d67c4c307a5.tar.gz
webtrees-938cf28f38ea24f59c60e45eacd92d67c4c307a5.tar.bz2
webtrees-938cf28f38ea24f59c60e45eacd92d67c4c307a5.zip
#1256330 - Sitemap ignores privacy settings leading to 404 errors
-rw-r--r--modules_v3/sitemap/module.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/modules_v3/sitemap/module.php b/modules_v3/sitemap/module.php
index 60f461df7f..bdecb2d0b9 100644
--- a/modules_v3/sitemap/module.php
+++ b/modules_v3/sitemap/module.php
@@ -62,7 +62,8 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config {
}
}
- // The index file contains references to all the other files
+ // The index file contains references to all the other files.
+ // These files are the same for visitors/users/admins.
private function generate_index() {
// Check the cache
$timestamp=get_module_setting($this->getName(), 'sitemap.timestamp');
@@ -104,7 +105,7 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config {
}
}
$data='<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'.PHP_EOL.'<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.PHP_EOL.$data.'</sitemapindex>'.PHP_EOL;
- // Cache this data
+ // Cache this data.
set_module_setting($this->getName(), 'sitemap.xml', $data);
set_module_setting($this->getName(), 'sitemap.timestamp', WT_TIMESTAMP);
}
@@ -114,10 +115,11 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config {
}
// A separate file for each family tree and each record type.
+ // These files depend on access levels, so only cache for visitors.
private function generate_file($ged_id, $rec_type, $volume) {
// Check the cache
$timestamp=get_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp');
- if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE) {
+ if ($timestamp > WT_TIMESTAMP - self::CACHE_LIFE && !WT_USER_ID) {
$data=get_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.xml');
} else {
$tree=WT_Tree::get($ged_id);
@@ -200,9 +202,12 @@ class sitemap_WT_Module extends WT_Module implements WT_Module_Config {
}
}
$data='<'.'?xml version="1.0" encoding="UTF-8" ?'.'>'.PHP_EOL.'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'.PHP_EOL.$data.'</urlset>'.PHP_EOL;
- // Cache this data
- set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.xml', $data);
- set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp', WT_TIMESTAMP);
+ // Cache this data - but only for visitors, as we don’t want
+ // visitors to see data created by logged-in users.
+ if (!WT_USER_ID) {
+ set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.xml', $data);
+ set_module_setting($this->getName(), 'sitemap-'.$ged_id.'-'.$rec_type.'-'.$volume.'.timestamp', WT_TIMESTAMP);
+ }
}
header('Content-Type: application/xml');
header('Content-Length: '.strlen($data));