summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/Sitemapper.php12
-rw-r--r--inc/actions.php2
-rw-r--r--inc/init.php6
3 files changed, 17 insertions, 3 deletions
diff --git a/inc/Sitemapper.php b/inc/Sitemapper.php
index bbea73b52..1315ed448 100644
--- a/inc/Sitemapper.php
+++ b/inc/Sitemapper.php
@@ -100,7 +100,7 @@ class Sitemapper {
global $conf;
$sitemap = $conf['cachedir'].'/sitemap.xml';
- if($conf['compression'] === 'bz2' || $conf['compression'] === 'gz'){
+ if (self::sitemapIsCompressed()) {
$sitemap .= '.gz';
}
@@ -108,6 +108,16 @@ class Sitemapper {
}
/**
+ * Helper function for checking if the sitemap is compressed
+ *
+ * @return bool If the sitemap file is compressed
+ */
+ public static function sitemapIsCompressed() {
+ global $conf;
+ return $conf['compression'] === 'bz2' || $conf['compression'] === 'gz';
+ }
+
+ /**
* Pings search engines with the sitemap url. Plugins can add or remove
* urls to ping using the SITEMAP_PING event.
*
diff --git a/inc/actions.php b/inc/actions.php
index 62b0e1800..88576e1dc 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -637,7 +637,7 @@ function act_sitemap($act) {
}
$sitemap = Sitemapper::getFilePath();
- if(strrchr($sitemap, '.') === '.gz'){
+ if (Sitemapper::sitemapIsCompressed()) {
$mime = 'application/x-gzip';
}else{
$mime = 'application/xml; charset=utf-8';
diff --git a/inc/init.php b/inc/init.php
index 00ab2afe9..4105225ea 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -129,9 +129,13 @@ if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC',
// enable gzip compression if supported
$conf['gzip_output'] &= (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);
+global $ACT;
if ($conf['gzip_output'] &&
!defined('DOKU_DISABLE_GZIP_OUTPUT') &&
- function_exists('ob_gzhandler')) {
+ function_exists('ob_gzhandler') &&
+ // Disable compression when a compressed sitemap might be delivered
+ // See https://bugs.dokuwiki.org/index.php?do=details&task_id=2576
+ !($ACT == 'sitemap' && Sitemapper::sitemapIsCompressed())) {
ob_start('ob_gzhandler');
}