add cronjob to rebuild the sitemap
authorJoshua Rüsweg <josh@bastelstu.be>
Thu, 15 Jun 2017 19:05:09 +0000 (21:05 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Thu, 15 Jun 2017 19:05:19 +0000 (21:05 +0200)
com.woltlab.wcf/cronjob.xml
wcfsetup/install/files/lib/system/cronjob/RebuildSitemapCronjob.class.php [new file with mode: 0755]

index 2babef090102f28e5131e1927865d0313b448a8c..7480fa58d6e1a5f859d2c779bfcb47ae83fdb5e0 100644 (file)
                        <canbeedited>1</canbeedited>
                        <canbedisabled>1</canbedisabled>
                </cronjob>
+               
+               <cronjob name="com.woltlab.wcf.rebuildSitemap">
+                       <classname>wcf\system\cronjob\RebuildSitemapCronjob</classname>
+                       <description>Rebuilds the sitemap</description>
+                       <description language="de">Aktualisiert die Sitemap</description>
+                       <startminute>0</startminute>
+                       <starthour>3</starthour>
+                       <startdom>*</startdom>
+                       <startmonth>*</startmonth>
+                       <startdow>*</startdow>
+                       <canbeedited>1</canbeedited>
+                       <canbedisabled>1</canbedisabled>
+               </cronjob>
        </import>
        
        <delete>
diff --git a/wcfsetup/install/files/lib/system/cronjob/RebuildSitemapCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/RebuildSitemapCronjob.class.php
new file mode 100755 (executable)
index 0000000..92b9486
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace wcf\system\cronjob;
+use wcf\data\cronjob\Cronjob;
+use wcf\system\worker\SitemapRebuildWorker;
+
+/**
+ * Rebuild the sitemap. 
+ * 
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Cronjob
+ * @since      3.1
+ */
+class RebuildSitemapCronjob extends AbstractCronjob {
+       /**
+        * @inheritDoc
+        */
+       public function execute(Cronjob $cronjob) {
+               parent::execute($cronjob);
+               
+               $worker = new SitemapRebuildWorker([]);
+               $count = 0;
+               
+               while($worker->getProgress() < 100) {
+                       $worker->setLoopCount($count);
+                       $worker->execute();
+                       $count++;
+               }
+       }
+}