Fixed invalid number of tokens in prepared statement
authorMarcel Werk <burntime@woltlab.com>
Wed, 20 Jul 2011 18:55:16 +0000 (20:55 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 20 Jul 2011 18:55:16 +0000 (20:55 +0200)
com.woltlab.wcf.notification/files/lib/data/user/notification/recipient/UserNotificationRecpientList.class.php [deleted file]
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php

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 (file)
index d29a8c6..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-namespace wcf\data\user\notification\recipient;
-use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\data\user\notification\type\UserNotificationType;
-use wcf\data\user\UserList;
-
-/**
- * Decorates the user object to provide special functions for handling recipients of user notifications.
- * 
- * @author     Marcel Werk
- * @copyright  2001-2011 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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); 
-               }
-       }
-}
index 89b87b700488bcfe2e7ef169919c79f9ae61fd86..2cc734977edbae4967a8720e8480ab160d18b9c9 100644 (file)
@@ -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);