From: Matthias Schmidt Date: Mon, 8 Jul 2013 20:26:21 +0000 (+0200) Subject: Fixes issue with user activity point object processors X-Git-Tag: 2.0.0_Beta_5~87^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e470e331eb9599a29694577ee03f7caf19588505;p=GitHub%2FWoltLab%2FWCF.git Fixes issue with user activity point object processors --- diff --git a/wcfsetup/install/files/lib/system/user/activity/point/AbstractUserActivityPointObjectProcessor.class.php b/wcfsetup/install/files/lib/system/user/activity/point/AbstractUserActivityPointObjectProcessor.class.php new file mode 100644 index 0000000000..b3b2cedca3 --- /dev/null +++ b/wcfsetup/install/files/lib/system/user/activity/point/AbstractUserActivityPointObjectProcessor.class.php @@ -0,0 +1,21 @@ + + * @package com.woltlab.wcf + * @subpackage system.user.activity.point + * @category Community Framework + */ +abstract class AbstractUserActivityPointObjectProcessor extends AbstractObjectTypeProcessor implements IUserActivityPointObjectProcessor { + /** + * number of objects processed during one request + * @var integer + */ + public $limit = 500; +} diff --git a/wcfsetup/install/files/lib/system/user/activity/point/DefaultUserActivityPointObjectProcessor.class.php b/wcfsetup/install/files/lib/system/user/activity/point/DefaultUserActivityPointObjectProcessor.class.php index bf431858fa..dfcd5110cb 100644 --- a/wcfsetup/install/files/lib/system/user/activity/point/DefaultUserActivityPointObjectProcessor.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/point/DefaultUserActivityPointObjectProcessor.class.php @@ -11,7 +11,7 @@ namespace wcf\system\user\activity\point; * @subpackage system.user.activity.point * @category Community Framework */ -class DefaultUserActivityPointObjectProcessor implements IUserActivityPointObjectProcessor { +class DefaultUserActivityPointObjectProcessor extends AbstractUserActivityPointObjectProcessor { /** * @see wcf\system\user\activity\point\IUserActivityPointObject::countRequests(); */ diff --git a/wcfsetup/install/files/lib/system/user/activity/point/IUserActivityPointObjectProcessor.class.php b/wcfsetup/install/files/lib/system/user/activity/point/IUserActivityPointObjectProcessor.class.php index 9261b13645..6ca00bae61 100644 --- a/wcfsetup/install/files/lib/system/user/activity/point/IUserActivityPointObjectProcessor.class.php +++ b/wcfsetup/install/files/lib/system/user/activity/point/IUserActivityPointObjectProcessor.class.php @@ -1,5 +1,6 @@ objectType = $objectType; - } - +class ReceivedLikesUserActivityPointObjectProcessor extends AbstractUserActivityPointObjectProcessor { /** - * @see wcf\system\user\activity\point\IUserActivityPointObject::countRequests(); + * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::countRequests(); */ public function countRequests() { - $sql = "SELECT COUNT(*) AS count + $sql = "SELECT COUNT(*) FROM wcf".WCF_N."_like WHERE likeValue = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(Like::LIKE)); - $row = $statement->fetchArray(); - return ceil($row['count'] / $this->limit) + 1; + return ceil($statement->fetchColumn() / $this->limit) + 1; } /** - * @see wcf\system\user\activity\point\IUserActivityPointObject::updateActivityPointEvents(); + * @see wcf\system\user\activity\point\IUserActivityPointObjectProcessor::updateActivityPointEvents(); */ public function updateActivityPointEvents($request) { if ($request == 0) { @@ -52,7 +38,7 @@ class ReceivedLikesUserActivityPointObjectProcessor implements IUserActivityPoin $sql = "DELETE FROM wcf".WCF_N."_user_activity_point_event WHERE objectTypeID = ?"; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->objectType->objectTypeID)); + $statement->execute(array($this->objectTypeID)); } else { $sql = "SELECT likeID @@ -69,7 +55,7 @@ class ReceivedLikesUserActivityPointObjectProcessor implements IUserActivityPoin if (empty($likeIDs)) return; $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add("objectTypeID = ?", array($this->objectType->objectTypeID)); + $conditionBuilder->add("objectTypeID = ?", array($this->objectTypeID)); $conditionBuilder->add("objectID IN (?)", array($likeIDs)); // avoid problems with duplicate keys, as likes may be created in the meantime @@ -80,7 +66,8 @@ class ReceivedLikesUserActivityPointObjectProcessor implements IUserActivityPoin $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add("likeID IN (?)", array($likeIDs)); - // use INSERT … SELECT as this makes bulk updating easier + + // use INSERT ... SELECT as this makes bulk updating easier $sql = "INSERT INTO wcf".WCF_N."_user_activity_point_event (userID, objectTypeID, objectID, additionalData) SELECT objectUserID AS userID, @@ -90,7 +77,10 @@ class ReceivedLikesUserActivityPointObjectProcessor implements IUserActivityPoin FROM wcf".WCF_N."_like ".$conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array_merge(array($this->objectType->objectTypeID, serialize(array())), $conditionBuilder->getParameters())); + $statement->execute(array_merge(array( + $this->objectTypeID, + serialize(array()) + ), $conditionBuilder->getParameters())); } } }