Adds update script to remove likes for deleted comment responses
authorMatthias Schmidt <gravatronics@live.com>
Sat, 15 Mar 2014 16:49:10 +0000 (17:49 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 15 Mar 2014 16:49:10 +0000 (17:49 +0100)
com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.3.php [deleted file]
wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.4.php [new file with mode: 0644]

index 0c84515616a78d18da695454167c082f0194a516..4b6750fc6530af3a80177b40fb72989bcea63da4 100644 (file)
@@ -5,7 +5,7 @@
                <packagedescription><![CDATA[Free web-framework, designed and developed for complex community applications.]]></packagedescription>
                <packagedescription language="de"><![CDATA[Freies Web-Framework, das für komplexe Community-Anwendungen entworfen und entwickelt wurde.]]></packagedescription>
                <isapplication>1</isapplication>
-               <version>2.0.3</version> <!-- codename: maelstrom -->
+               <version>2.0.4</version> <!-- codename: maelstrom -->
                <date>2014-03-02</date>
        </packageinformation>
        
                <instruction type="userMenu">userMenu.xml</instruction>
                <instruction type="userNotificationEvent">userNotificationEvent.xml</instruction>
                <instruction type="aclOption">aclOption.xml</instruction>
-               <instruction type="script">acp/post_install.php</instruction> 
+               <instruction type="script">acp/post_install.php</instruction>
        </instructions>
        
-       <instructions type="update" fromversion="2.0.2 pl 1">
+       <instructions type="update" fromversion="2.0.3">
                <instruction type="acpTemplate">acptemplates_update.tar</instruction>
                <instruction type="file">files_update.tar</instruction>
                <instruction type="template">templates_update.tar</instruction>
-               <instruction type="script">acp/update_com.woltlab.wcf_2.0.3.php</instruction>
+               <instruction type="script">acp/update_com.woltlab.wcf_2.0.4.php</instruction>
                
-               <instruction type="language">languages/*.xml</instruction>
-               <instruction type="option">option.xml</instruction>
+               <!-- todo: other pips -->
        </instructions>
 </package>
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.3.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.3.php
deleted file mode 100644 (file)
index 144f9fd..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-use wcf\system\WCF;
-
-/**
- * @author     Alexander Ebert
- * @copyright  2001-2014 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    com.woltlab.wcf
- * @category   Community Framework
- */
-// enforce new limits for session timeout (prevents misconfiguration)
-$sql = "SELECT optionID, optionValue
-       FROM    wcf".WCF_N."_option
-       WHERE   optionName = ?";
-$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array('session_timeout'));
-$row = $statement->fetchArray();
-
-$sql = "UPDATE wcf".WCF_N."_option
-       SET     optionValue = ?
-       WHERE   optionID = ?";
-$statement = WCF::getDB()->prepareStatement($sql);
-$statement->execute(array(
-       min(max(600, $row['optionValue']), 86400),
-       $row['optionID']
-));
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.4.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.4.php
new file mode 100644 (file)
index 0000000..7917407
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+use wcf\data\like\object\LikeObjectList;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\like\LikeHandler;
+
+/**
+ * @author     Matthias Schmidt
+ * @copyright  2001-2014 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @category   Community Framework
+ */
+// delete likes for deleted comments responses
+$likeObjectList = new LikeObjectList();
+$likeObjectList->sqlJoins = "LEFT JOIN wcf".WCF_N."_comment_response comment_response ON (comment_response.responseID = like_object.objectID)";
+$likeObjectList->getConditionBuilder()->add('like_object.objectTypeID = ?', array(ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.like.likeableObject', 'com.woltlab.wcf.comment.response')));
+$likeObjectList->getConditionBuilder()->add('comment_response.responseID IS NULL');
+$likeObjectList->readObjects();
+
+$deletedResponseIDs = array();
+foreach ($likeObjectList as $likeObject) {
+       $deletedResponseIDs[] = $likeObject->objectID;
+}
+
+LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $deletedResponseIDs);