From: Marcel Werk Date: Wed, 20 Jul 2011 18:55:16 +0000 (+0200) Subject: Fixed invalid number of tokens in prepared statement X-Git-Tag: 2.0.0_Beta_1~1986 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=da04986b26088775764b9a6e8af839231f6f76c7;p=GitHub%2FWoltLab%2FWCF.git Fixed invalid number of tokens in prepared statement --- diff --git a/com.woltlab.wcf.notification/files/lib/data/user/notification/recipient/UserNotificationRecpientList.class.php b/com.woltlab.wcf.notification/files/lib/data/user/notification/recipient/UserNotificationRecpientList.class.php deleted file mode 100644 index d29a8c6591..0000000000 --- a/com.woltlab.wcf.notification/files/lib/data/user/notification/recipient/UserNotificationRecpientList.class.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @package com.woltlab.wcf.notification - * @subpackage data.user.notification.user - * @category Community Framework - */ -class UserNotificationRecipientList extends UserList { - /** - * @see wcf\data\DatabaseObjectList\DatabaseObjectList::readObjects() - */ - public function readObjects() { - if ($this->objectIDs === null) { - $this->readObjectIDs(); - } - - if (!count($this->objectIDs)) { - return; - } - - // get notification types - $notificationTypes = array(); - $conditionBuilder = new PreparedStatementConditionBuilder(); - $conditionBuilder->add('event_to_user.userID IN (?)', array($this->objectIDs)); - $conditionBuilder->add('event_to_user.enabled = ?', array(1)); - - $sql = "SELECT event_to_user.eventID, event_to_user.userID, notification_type.* - FROM wcf".WCF_N."_user_notification_event_to_user event_to_user - LEFT JOIN wcf".WCF_N."_user_notification_type notification_type - ON (notification_type.notificationTypeID = event_to_user.notificationTypeID) - ".$conditionBuilder->__toString(); - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($conditionBuilder->getParameters()); - while ($row = $statement->fetchArray()) { - $notificationTypes[$row['userID']][$row['eventID']] = new UserNotificationType(null, $row); - } - - // get users - $sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.',' : '')." - ".$this->getDatabaseTableAlias().".* - FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()." - ".$this->sqlJoins." - WHERE ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." IN (?".str_repeat(',?', count($this->objectIDs)).") - ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : ''); - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute($this->objectIDs); - while ($row = $statement->fetchArray()) { - $row['notificationTypes'] = (isset($notificationTypes[$row['userID']]) ? $notificationTypes[$row['userID']] : array()); - $this->objects[] = new UserNotificationRecipient(null, $row); - } - } -} diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php index 89b87b7004..2cc734977e 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php @@ -137,7 +137,7 @@ abstract class DatabaseObjectList { ".$this->getDatabaseTableAlias().".* FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()." ".$this->sqlJoins." - WHERE ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." IN (?".str_repeat(',?', count($this->objectIDs)).") + WHERE ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." IN (?".str_repeat(',?', count($this->objectIDs) - 1).") ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : ''); $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($this->objectIDs);