Prevent outdated sitemap index file
authorJoshua Rüsweg <josh@bastelstu.be>
Wed, 3 Jan 2018 16:32:14 +0000 (17:32 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Wed, 3 Jan 2018 16:32:14 +0000 (17:32 +0100)
If we have no active sitemap objects, the sitemap index file were not updated and has an outdated value.

wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php

index 289092ec7832886d2ef7a304b43706cb67a43b2f..4f664a1767cc424d4bc4aa07f1b561390e9c5852 100755 (executable)
@@ -122,6 +122,11 @@ class SitemapRebuildWorker extends AbstractWorker {
                                $this->storeWorkerData();
                        }
                        
+                       // write sitemap index file if we have no active sitemap objects to prevent an outdated index file
+                       if (empty($this->sitemapObjects) && $this->loopCount == 0) {
+                               $this->writeIndexFile();
+                       }
+                       
                        // check whether we should rebuild it
                        if (!isset($this->parameters['forceRebuild']) || !$this->parameters['forceRebuild'] && !$this->workerData['finished']) {
                                $this->checkCache();