Fix closing files in sitemap rebuild worker
authorJoshua Rüsweg <josh@bastelstu.be>
Fri, 6 Oct 2017 13:12:31 +0000 (15:12 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Fri, 6 Oct 2017 13:12:50 +0000 (15:12 +0200)
wcfsetup/install/files/lib/system/worker/SitemapRebuildWorker.class.php

index 7544c9d594cf27b00f9d4922d5b8b9f92c09eeb8..96d1af43855ae33bf0765ebb61d65fe76ebca72f 100755 (executable)
@@ -182,6 +182,7 @@ class SitemapRebuildWorker extends AbstractWorker {
                                $this->workerData['dataCount'] = 0;
                        }
                        
+                       $closeFile = true;
                        // finish sitemap
                        if (count($objectList) < $this->limit) {
                                if ($this->workerData['dataCount'] > 0) {
@@ -196,12 +197,13 @@ class SitemapRebuildWorker extends AbstractWorker {
                                
                                if (count($this->sitemapObjects) <= $this->workerData['sitemap']) {
                                        $this->writeIndexFile();
+                                       $closeFile = false;
                                }
                        }
                        
                        $this->workerData['sitemapLoopCount']++;
                        $this->storeWorkerData();
-                       $this->closeFile();
+                       if ($closeFile) $this->closeFile();
                } 
                finally {
                        // change session owner back to the actual user
@@ -254,6 +256,8 @@ class SitemapRebuildWorker extends AbstractWorker {
                
                $this->workerData['finished'] = true;
                
+               $this->closeFile();
+               
                if ($this->workerData['tmpFile'] && file_exists($this->workerData['tmpFile'])) {
                        unlink($this->workerData['tmpFile']);
                }