<classname><![CDATA[wcf\system\worker\LikeUserRebuildDataWorker]]></classname>
<nicevalue>-90</nicevalue>
</type>
+ <type>
+ <name>com.woltlab.wcf.poll</name>
+ <definitionname>com.woltlab.wcf.rebuildData</definitionname>
+ <classname><![CDATA[wcf\system\worker\PollRebuildDataWorker]]></classname>
+ <nicevalue>60</nicevalue>
+ </type>
<type>
<name>com.woltlab.wcf.user</name>
<definitionname>com.woltlab.wcf.rebuildData</definitionname>
--- /dev/null
+<?php
+namespace wcf\system\worker;
+use wcf\data\poll\PollList;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\WCF;
+
+/**
+ * Worker implementation for updating polls.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.worker
+ * @category Community Framework
+ */
+class PollRebuildDataWorker extends AbstractRebuildDataWorker {
+ /**
+ * @inheritDoc
+ */
+ protected $objectListClassName = PollList::class;
+
+ /**
+ * @inheritDoc
+ */
+ protected $limit = 10;
+
+ /**
+ * @inheritDoc
+ */
+ protected function initObjectList() {
+ parent::initObjectList();
+
+ $this->objectList->sqlOrderBy = 'poll.pollID';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function execute() {
+ parent::execute();
+
+ $pollIDs = [];
+ foreach ($this->getObjectList() as $poll) {
+ $pollIDs[] = $poll->pollID;
+ }
+
+ if (!empty($pollIDs)) {
+ // update poll options
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add('poll_option.pollID IN (?)', [$pollIDs]);
+ $sql = "UPDATE wcf" . WCF_N . "_poll_option poll_option
+ SET votes = (
+ SELECT COUNT(*)
+ FROM wcf" . WCF_N . "_poll_option_vote
+ WHERE optionID = poll_option.optionID
+ )
+ " . $conditionBuilder;
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+
+ // update polls
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add('poll.pollID IN (?)', [$pollIDs]);
+ $sql = "UPDATE wcf" . WCF_N . "_poll poll
+ SET votes = (
+ SELECT COUNT(*)
+ FROM wcf" . WCF_N . "_poll_option_vote
+ WHERE pollID = poll.pollID
+ )
+ " . $conditionBuilder;
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+ }
+ }
+}
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment.description"><![CDATA[Erzeugt Vorschaubilder neu]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily"><![CDATA[Statistiken aktualisieren]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily.description"><![CDATA[Erzeugt die täglichen Statistiken neu]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.poll"><![CDATA[Umfragen aktualisieren]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.poll.description"><![CDATA[Aktualisiert Zähler der Umfragen]]></item>
</category>
<category name="wcf.acp.rescueMode">
<item name="wcf.acp.rebuildData.com.woltlab.wcf.attachment.description"><![CDATA[Rebuilds the attachment preview images.]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily"><![CDATA[Rebuild Statistics]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.statDaily.description"><![CDATA[Rebuilds the daily statistics.]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.poll"><![CDATA[Rebuild Polls]]></item>
+ <item name="wcf.acp.rebuildData.com.woltlab.wcf.poll.description"><![CDATA[Rebuilds the poll counters.]]></item>
</category>
<category name="wcf.acp.rescueMode">