From 7b56f1f82742a9cdbc99c6e5c97b6385ccd12140 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 15 Mar 2014 17:49:10 +0100 Subject: [PATCH] Adds update script to remove likes for deleted comment responses --- com.woltlab.wcf/package.xml | 11 ++++---- .../acp/update_com.woltlab.wcf_2.0.3.php | 26 ------------------- .../acp/update_com.woltlab.wcf_2.0.4.php | 25 ++++++++++++++++++ 3 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.3.php create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.4.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 0c84515616..4b6750fc65 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -5,7 +5,7 @@ 1 - 2.0.3 + 2.0.4 2014-03-02 @@ -40,16 +40,15 @@ userMenu.xml userNotificationEvent.xml aclOption.xml - acp/post_install.php + acp/post_install.php - + acptemplates_update.tar files_update.tar templates_update.tar - acp/update_com.woltlab.wcf_2.0.3.php + acp/update_com.woltlab.wcf_2.0.4.php - languages/*.xml - option.xml + 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 index 144f9fd5ed..0000000000 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.3.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @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 index 0000000000..7917407b04 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_2.0.4.php @@ -0,0 +1,25 @@ + + * @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); -- 2.20.1