<instruction type="userProfileMenu">userProfileMenu.xml</instruction>
<instruction type="script" run="standalone">acp/update_mqc_com.woltlab.wcf_2.1.php</instruction>
+ <instruction type="script" run="standalone">acp/rebuild_comments_com.woltlab.wcf_2.1.php</instruction>
</instructions>
<instructions type="update" fromversion="2.1.0 Beta 3">
<instruction type="option">option.xml</instruction>
<instruction type="userMenu">userMenu.xml</instruction>
+
+ <instruction type="script" run="standalone">acp/rebuild_comments_com.woltlab.wcf_2.1.php</instruction>
</instructions>
</package>
--- /dev/null
+<?php
+use wcf\system\WCF;
+use wcf\system\package\SplitNodeException;
+
+/**
+ * @author Alexander Ebert
+ * @copyright 2001-2015 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @category Community Framework
+ */
+$rebuildData = WCF::getSession()->getVar('__wcfUpdateRebuildComments');
+if ($rebuildData === null) {
+ $sql = "SELECT COUNT(*) AS count
+ FROM wcf".WCF_N."_comment
+ WHERE responses > ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(3));
+ $row = $statement->fetchSingleRow();
+
+ $rebuildData = array(
+ 'i' => 0,
+ 'max' => 0
+ );
+
+ if ($row['count']) {
+ $rebuildData['max'] = ceil($row['count'] / 50);
+ }
+}
+
+if ($rebuildData['max']) {
+ $offset = $rebuildData['i'] * 50;
+
+ // get comments
+ $sql = "SELECT commentID
+ FROM wcf".WCF_N."_comment
+ WHERE responses > ?
+ ORDER BY commentID";
+ $statement = WCF::getDB()->prepareStatement($sql, 50, $offset);
+ $statement->execute(array(3));
+
+ $commentData = array();
+ while ($row = $statement->fetchArray()) {
+ $commentData[$row['commentID']] = array();
+ }
+
+ if (empty($commentData)) {
+ WCF::getSession()->unregister('__wcfUpdateRebuildComments');
+ }
+ else {
+ // get responses per comment
+ $sql = "SELECT responseID
+ FROM wcf".WCF_N."_comment_response
+ WHERE commentID = ?
+ ORDER BY time";
+ $statement = WCF::getDB()->prepareStatement($sql, 5);
+
+ foreach ($commentData as $commentID => &$responseIDs) {
+ $statement->execute(array($commentID));
+ while ($row = $statement->fetchArray()) {
+ $responseIDs[] = $row['responseID'];
+ }
+
+ $responseIDs = serialize($responseIDs);
+ }
+
+ // set responseIDs per comment
+ $sql = "UPDATE wcf".WCF_N."_comment
+ SET responseIDs = ?
+ WHERE commentID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ WCF::getDB()->beginTransaction();
+ foreach ($commentData as $commentID => $responseIDs) {
+ $statement->execute(array(
+ $responseIDs,
+ $commentID
+ ));
+ }
+ WCF::getDB()->commitTransaction();
+
+ $rebuildData['i']++;
+ WCF::getSession()->register('__wcfUpdateRebuildComments', $rebuildData);
+
+ // call this script again
+ throw new SplitNodeException();
+ }
+}
+
* Provides functions to edit comments.
*
* @author Alexander Ebert
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.comment
FROM wcf".WCF_N."_comment_response
WHERE commentID = ?
ORDER BY time ASC";
- $statement = WCF::getDB()->prepareStatement($sql, 3);
+ $statement = WCF::getDB()->prepareStatement($sql, 5);
$statement->execute(array($this->commentID));
$responseIDs = array();
while ($row = $statement->fetchArray()) {
* Default implementation for comment managers.
*
* @author Alexander Ebert
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.comment.manager
* display comments per page
* @var integer
*/
- public $commentsPerPage = 10;
+ public $commentsPerPage = 30;
/**
* permission name for comment/response creation