Add PreparedStatement::fetchColumns()
authorMatthias Schmidt <gravatronics@live.com>
Sat, 7 May 2016 20:38:01 +0000 (22:38 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 7 May 2016 20:38:01 +0000 (22:38 +0200)
40 files changed:
wcfsetup/install/files/lib/acp/action/UserQuickSearchAction.class.php
wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php
wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/page/UserListPage.class.php
wcfsetup/install/files/lib/data/DatabaseObjectList.class.php
wcfsetup/install/files/lib/data/attachment/AttachmentAction.class.php
wcfsetup/install/files/lib/data/bbcode/BBCodeAction.class.php
wcfsetup/install/files/lib/data/box/Box.class.php
wcfsetup/install/files/lib/data/comment/CommentEditor.class.php
wcfsetup/install/files/lib/data/label/LabelAction.class.php
wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/data/style/StyleEditor.class.php
wcfsetup/install/files/lib/data/user/TeamList.class.php
wcfsetup/install/files/lib/data/user/User.class.php
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php
wcfsetup/install/files/lib/data/user/follow/UserFollowingAction.class.php
wcfsetup/install/files/lib/data/user/profile/visitor/UserProfileVisitorAction.class.php
wcfsetup/install/files/lib/form/SearchForm.class.php
wcfsetup/install/files/lib/form/UserSearchForm.class.php
wcfsetup/install/files/lib/system/cronjob/AttachmentCleanUpCronjob.class.php
wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php
wcfsetup/install/files/lib/system/cronjob/ModerationQueueCronjob.class.php
wcfsetup/install/files/lib/system/cronjob/UserQuitCronjob.class.php
wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php
wcfsetup/install/files/lib/system/edit/EditHistoryManager.class.php
wcfsetup/install/files/lib/system/importer/AbstractCommentResponseImporter.class.php
wcfsetup/install/files/lib/system/importer/UserImporter.class.php
wcfsetup/install/files/lib/system/moderation/queue/AbstractModerationQueueHandler.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationScheduler.class.php
wcfsetup/install/files/lib/system/package/plugin/BoxPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/session/SessionHandler.class.php
wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php
wcfsetup/install/files/lib/system/user/notification/object/type/TMultiRecipientModerationQueueCommentUserNotificationObjectType.class.php
wcfsetup/install/files/lib/system/user/object/watch/UserObjectWatchHandler.class.php

index 5bed3552b779b454877bab1587b9d13c5cda91ea..effab7b6395244d3167494ea5052946aded4fbfa 100644 (file)
@@ -97,9 +97,7 @@ class UserQuickSearchAction extends AbstractAction {
                                        WHERE           banned = ?";
                                $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
                                $statement->execute(array(1));
-                               while ($row = $statement->fetchArray()) {
-                                       $this->matches[] = $row['userID'];
-                               }
+                               $this->matches = $statement->fetchColumns();
                                break;
                                
                        case 'newest':
@@ -113,9 +111,7 @@ class UserQuickSearchAction extends AbstractAction {
                                        ORDER BY        user_table.registrationDate DESC";
                                $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
                                $statement->execute();
-                               while ($row = $statement->fetchArray()) {
-                                       $this->matches[] = $row['userID'];
-                               }
+                               $this->matches = $statement->fetchColumns();
                                break;
                        
                        case 'disabled':
@@ -129,9 +125,7 @@ class UserQuickSearchAction extends AbstractAction {
                                        ORDER BY        user_table.registrationDate DESC";
                                $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
                                $statement->execute(array(0));
-                               while ($row = $statement->fetchArray()) {
-                                       $this->matches[] = $row['userID'];
-                               }
+                               $this->matches = $statement->fetchColumns();
                                break;
                        
                        case 'disabledAvatars':
@@ -142,9 +136,7 @@ class UserQuickSearchAction extends AbstractAction {
                                        WHERE           disableAvatar = ?";
                                $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
                                $statement->execute(array(1));
-                               while ($row = $statement->fetchArray()) {
-                                       $this->matches[] = $row['userID'];
-                               }
+                               $this->matches = $statement->fetchColumns();
                                break;
                                        
                        case 'disabledSignatures':
@@ -155,9 +147,7 @@ class UserQuickSearchAction extends AbstractAction {
                                        WHERE           disableSignature = ?";
                                $statement = WCF::getDB()->prepareStatement($sql, $this->maxResults);
                                $statement->execute(array(1));
-                               while ($row = $statement->fetchArray()) {
-                                       $this->matches[] = $row['userID'];
-                               }
+                               $this->matches = $statement->fetchColumns();
                                break;
                }
                
index 7d3f6f57fb1a19fede614f8f43c72e907a1c2b6a..f861b04d477a7788b8f1de05a5be798ac973e68d 100644 (file)
@@ -317,10 +317,7 @@ class BoxAddForm extends AbstractForm {
                                " . $conditionBuilder;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditionBuilder->getParameters());
-                       $this->pageIDs = [];
-                       while ($row = $statement->fetchArray()) {
-                               $this->pageIDs[] = $row['pageID'];
-                       }
+                       $this->pageIDs = $statement->fetchColumns();
                }
                
                // validate images
index 68e9c3ad35b35d9c31db848c8a322fa132d7a527..6c94b85c8d07686d907449450178ee42b7a2bb7a 100644 (file)
@@ -132,10 +132,7 @@ class MenuAddForm extends AbstractForm {
                                " . $conditionBuilder;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditionBuilder->getParameters());
-                       $this->pageIDs = [];
-                       while ($row = $statement->fetchArray()) {
-                               $this->pageIDs[] = $row['pageID'];
-                       }
+                       $this->pageIDs = $statement->fetchColumns();
                }
        }
        
index 437b5c3caa479ee22bda943ad8a5e7aa69e81c47..ca1002f98d1725a779e5f85335b0f9ceb4ae40f0 100644 (file)
@@ -336,10 +336,7 @@ class StyleAddForm extends AbstractForm {
                        FROM    wcf".WCF_N."_style_variable";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $variables = [];
-               while ($row = $statement->fetchArray()) {
-                       $variables[] = $row['variableName'];
-               }
+               $variables = $statement->fetchColumns();
                
                $lines = explode("\n", StringUtil::unifyNewlines($this->variables['overrideScss']));
                $regEx = new Regex('^@([a-zA-Z]+): ?([@a-zA-Z0-9 ,\.\(\)\%\#-]+);$');
index ff52bf4830489c06ea3cb4e367ba28906013a4ff..2beb0b4f5a7b3153987cc2dfea4856eb8598286f 100755 (executable)
@@ -233,7 +233,6 @@ class UserListPage extends SortablePage {
         */
        protected function readUsers() {
                // get user ids
-               $userIDs = [];
                $sql = "SELECT          user_table.userID
                        FROM            wcf".WCF_N."_user user_table
                        ".(isset($this->options[$this->sortField]) ? "LEFT JOIN wcf".WCF_N."_user_option_value user_option_value ON (user_option_value.userID = user_table.userID)" : '')."
@@ -241,9 +240,7 @@ class UserListPage extends SortablePage {
                        ORDER BY        ".(($this->sortField != 'email' && isset($this->options[$this->sortField])) ? 'user_option_value.userOption'.$this->options[$this->sortField]->optionID : $this->sortField)." ".$this->sortOrder;
                $statement = WCF::getDB()->prepareStatement($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
                $statement->execute($this->conditions->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                // get user data
                if (!empty($userIDs)) {
index 104e3438858ac565ddc74a0dff6c63c7bf12d0af..1bef8c98939ade9f5a653766fdfa4528507b2305 100644 (file)
@@ -165,9 +165,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject {
                                ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : '');
                $statement = WCF::getDB()->prepareStatement($sql, $this->sqlLimit, $this->sqlOffset);
                $statement->execute($this->getConditionBuilder()->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $this->objectIDs[] = $row['objectID'];
-               }
+               $this->objectIDs = $statement->fetchColumns();
        }
        
        /**
index d3d4d67622c5e6930e08aaa9b748b35050ba8486..171e0713fc102ae9e26fd132f3988124d746c060 100644 (file)
@@ -245,7 +245,6 @@ class AttachmentAction extends AbstractDatabaseObjectAction implements ISortable
                $this->parameters['attachmentIDs'] = ArrayUtil::toIntegerArray($this->parameters['attachmentIDs']);
                
                // check attachment ids
-               $attachmentIDs = [];
                $conditions = new PreparedStatementConditionBuilder();
                $conditions->add("attachmentID IN (?)", [$this->parameters['attachmentIDs']]);
                $conditions->add("objectTypeID = ?", [$objectType->objectTypeID]);
@@ -262,9 +261,7 @@ class AttachmentAction extends AbstractDatabaseObjectAction implements ISortable
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $attachmentIDs[] = $row['attachmentID'];
-               }
+               $attachmentIDs = $statement->fetchColumns();
                
                foreach ($this->parameters['attachmentIDs'] as $attachmentID) {
                        if (!in_array($attachmentID, $attachmentIDs)) {
index 444214adfe1211c8eee740b9902befd0b86d07ec..2ef4ed8e9567f88644557c1bf41ae01f4a80f9e4 100644 (file)
@@ -51,11 +51,7 @@ class BBCodeAction extends AbstractDatabaseObjectAction implements IToggleAction
                        WHERE   optionType = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array('BBCodeSelect'));
-               
-               $optionIDs = array();
-               while ($optionID = $statement->fetchColumn()) {
-                       $optionIDs[] = $optionID;
-               }
+               $optionIDs = $statement->fetchColumns();
                
                if (!empty($optionIDs)) {
                        $conditionBuilder = new PreparedStatementConditionBuilder();
index 15a5acac0d0216a044ed3ec44496223785694fec..3d3d6a56aa61a13b7b08bb74b8e2b7ea45ca4ea3 100644 (file)
@@ -454,15 +454,13 @@ class Box extends DatabaseObject {
         */
        public function getPageIDs() {
                if ($this->pageIDs === null) {
-                       $this->pageIDs = [];
                        $sql = "SELECT  pageID
                                FROM    wcf" . WCF_N . "_box_to_page
                                WHERE   boxID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute([$this->boxID]);
-                       while ($pageID = $statement->fetchColumn()) {
-                               $this->pageIDs[] = $pageID;
-                       }
+                       
+                       $this->pageIDs = $statement->fetchColumns();
                }
                
                return $this->pageIDs;
index 2a581f8f7e648de90e6eb0ea2c35721852a99857..1903c579c95db788730b1bb567b0acc5f394f4e9 100644 (file)
@@ -29,10 +29,7 @@ class CommentEditor extends DatabaseObjectEditor {
                        ORDER BY        time ASC, responseID ASC";
                $statement = WCF::getDB()->prepareStatement($sql, 5);
                $statement->execute(array($this->commentID));
-               $responseIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $responseIDs[] = $row['responseID'];
-               }
+               $responseIDs = $statement->fetchColumns();
                
                $this->update(array(
                        'responseIDs' => serialize($responseIDs)
index 4908c4222a1686763607d9b3c946810b65d2cfa7..b3a90c19dca4be3b9f6ab8ed5de259dcd119fdae 100644 (file)
@@ -100,10 +100,7 @@ class LabelAction extends AbstractDatabaseObjectAction implements ISortableActio
                                        ".$conditions;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditions->getParameters());
-                               $languageItemIDs = [];
-                               while ($row = $statement->fetchArray()) {
-                                       $languageItemIDs[] = $row['languageItemID'];
-                               }
+                               $languageItemIDs = $statement->fetchColumns();
                                
                                $objectAction = new LanguageItemAction($languageItemIDs, 'delete');
                                $objectAction->executeAction();
index 941fc79f16b28a1eb17d73c31a34e391e11e70c2..43072696d6faffbfa441ce6234018682f5b448c9 100644 (file)
@@ -120,10 +120,7 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction {
                        ORDER BY        moderation_queue.lastChangeTime DESC";
                $statement = WCF::getDB()->prepareStatement($sql, 5);
                $statement->execute($conditions->getParameters());
-               $queueIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $queueIDs[] = $row['queueID'];
-               }
+               $queueIDs = $statement->fetchColumns();
                
                $queues = array();
                if (!empty($queueIDs)) {
index 42d7373003b979a3dc5ee81cc1a66d2e0e0cc76a..b40033b1cfec1480c01bb354e8d464a9fd676c21 100644 (file)
@@ -270,15 +270,12 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject {
         */
        public function getBoxIDs() {
                if ($this->boxIDs === null) {
-                       $this->boxIDs = [];
                        $sql = "SELECT  boxID
                                FROM    wcf" . WCF_N . "_box_to_page
                                WHERE   pageID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute([$this->pageID]);
-                       while ($row = $statement->fetchArray()) {
-                               $this->boxIDs[] = $row['boxID'];
-                       }
+                       $this->boxIDs = $statement->fetchColumns();
                }
                
                return $this->boxIDs;
index 6c0a623745036f129428c926d808d2810124ae50..7d541668cbd9c541430f2958cb9cbcb85a3b00df 100644 (file)
@@ -420,9 +420,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                                                WHERE   templateGroupID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$style->templateGroupID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $knownTemplates[] = $row['templateName'];
-                                       }
+                                       $knownTemplates = $statement->fetchColumns();
                                }
                                
                                // copy templates
index 0b89b4d6849b026488ec89b5c475a7c0d0a88dc2..6836c7bbd48ccb82fe1725cc3393f99861c3b1f5 100644 (file)
@@ -51,9 +51,7 @@ class TeamList extends UserProfileList {
                        ORDER BY        user_group.priority DESC".(!empty($this->sqlOrderBy) ? ", ".$this->sqlOrderBy : '');
                $statement = WCF::getDB()->prepareStatement($sql, $this->sqlLimit, $this->sqlOffset);
                $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $this->objectIDs[] = $row['objectID'];
-               }
+               $this->objectIDs = $statement->fetchColumns();
        }
        
        /**
index 93519df6a11b4688e80c5db1bc2a01023a61b949..c9fb30732283d051fc97eb82bb7c98a361df7334 100644 (file)
@@ -203,15 +203,12 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
                                
                                // cache does not exist or is outdated
                                if ($data === null || $skipCache) {
-                                       $this->groupIDs = [];
                                        $sql = "SELECT  groupID
                                                FROM    wcf".WCF_N."_user_to_group
                                                WHERE   userID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$this->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->groupIDs[] = $row['groupID'];
-                                       }
+                                       $this->groupIDs = $statement->fetchColumns();
                                        
                                        // update storage data
                                        if (!$skipCache) {
@@ -249,9 +246,7 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
                                                WHERE   userID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$this->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->languageIDs[] = $row['languageID'];
-                                       }
+                                       $this->languageIDs = $statement->fetchColumns();
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update($this->userID, 'languageIDs', serialize($this->languageIDs));
index 5d237cf103d3ec85f59ebe25038eb8c9344243ad..251c8127eac7b9165af9f456d90fe7917e6ea703 100644 (file)
@@ -95,11 +95,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               
-               $groupIDs = [];
-               while ($row = $statement->fetchArray()) {
-                       $groupIDs[] = $row['groupID'];
-               }
+               $groupIDs = $statement->fetchColumns();
                
                if (!UserGroup::isAccessibleGroup($groupIDs)) {
                        throw new PermissionDeniedException();
index 9b7418de4dbacb70f783057016fd49a10d2ce1c0..934dbac13195c8702c1d09513b437c09b4176aac 100644 (file)
@@ -168,9 +168,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
                                                WHERE   userID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$this->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->followingUserIDs[] = $row['followUserID'];
-                                       }
+                                       $this->followingUserIDs = $statement->fetchColumns();
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update($this->userID, 'followingUserIDs', serialize($this->followingUserIDs));
@@ -204,9 +202,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
                                                WHERE   followUserID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$this->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->followerUserIDs[] = $row['userID'];
-                                       }
+                                       $this->followerUserIDs = $statement->fetchColumns();
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update($this->userID, 'followerUserIDs', serialize($this->followerUserIDs));
@@ -240,9 +236,7 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
                                                WHERE   userID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([$this->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->ignoredUserIDs[] = $row['ignoreUserID'];
-                                       }
+                                       $this->ignoredUserIDs = $statement->fetchColumns();
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update($this->userID, 'ignoredUserIDs', serialize($this->ignoredUserIDs));
index 389b6347a986d3ef2a6713b4393f8f8978733322..38a9b0f14ada3a4f1d339c9edb16a0e8d9a59183 100644 (file)
@@ -198,10 +198,7 @@ class UserFollowAction extends AbstractDatabaseObjectAction implements IGroupedU
                        WHERE   followUserID = ?";
                $statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
                $statement->execute(array($this->parameters['userID']));
-               $userIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                // create group
                $group = new GroupedUserList();
index 79c4726578e23859049ab260dc7a0360255a703c..46f79b55ee898f255f1d348d5e68a98c297d5b23 100644 (file)
@@ -52,10 +52,7 @@ class UserFollowingAction extends UserFollowAction {
                        WHERE   userID = ?";
                $statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
                $statement->execute(array($this->parameters['userID']));
-               $userIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['followUserID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                // create group
                $group = new GroupedUserList();
index df6e3a76a09b97e5790dad2b068c2c566eb07271..c5ed9b5d09839de65f4dfe5c10d28c6985a1ce6f 100644 (file)
@@ -62,10 +62,7 @@ class UserProfileVisitorAction extends AbstractDatabaseObjectAction implements I
                        ORDER BY        time DESC";
                $statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
                $statement->execute(array($this->parameters['userID']));
-               $userIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                // create group
                $group = new GroupedUserList();
index 6bb83176e215f1de445ffb6971282d9995e30091..453181225695e73d06c7438ee1e7ff267e77e91f 100644 (file)
@@ -495,9 +495,7 @@ class SearchForm extends AbstractCaptchaForm {
                                WHERE   username ".($this->nameExactly ? "= ?" : "LIKE ?");
                        $statement = WCF::getDB()->prepareStatement($sql, 100);
                        $statement->execute(array($this->username.(!$this->nameExactly ? '%' : '')));
-                       while ($row = $statement->fetchArray()) {
-                               $userIDs[] = $row['userID'];
-                       }
+                       $userIDs = $statement->fetchColumns();
                        
                        if (empty($userIDs)) {
                                $this->throwNoMatchesException();
index 0eecfc025b63930c7c7fe6a5f064b77f92474214..04d6e7bf6b861bef3deddcfbab652a417d480e28 100644 (file)
@@ -175,9 +175,7 @@ class UserSearchForm extends UserOptionListForm {
                // do search
                $statement = WCF::getDB()->prepareStatement($sql.$this->conditions, $this->maxResults);
                $statement->execute($this->conditions->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $this->matches[] = $row['userID'];
-               }
+               $this->matches = $statement->fetchColumns();
        }
        
        /**
index 5215fe646a8188f521608263fab6b039ce6a340a..f7979d8fec26feda84b062aab4b388307b7a07ed 100644 (file)
@@ -22,7 +22,6 @@ class AttachmentCleanUpCronjob extends AbstractCronjob {
                parent::execute($cronjob);
                
                // delete orphaned attachments
-               $attachmentIDs = array();
                $sql = "SELECT  attachmentID
                        FROM    wcf".WCF_N."_attachment
                        WHERE   objectID = ?
@@ -32,9 +31,7 @@ class AttachmentCleanUpCronjob extends AbstractCronjob {
                        0,
                        (TIME_NOW - 86400)
                ));
-               while ($row = $statement->fetchArray()) {
-                       $attachmentIDs[] = $row['attachmentID'];
-               }
+               $attachmentIDs = $statement->fetchColumns();
                
                if (!empty($attachmentIDs)) {
                        AttachmentEditor::deleteAll($attachmentIDs);
index 8193471d02a5251052c81313cbb66520bfd101ae..dc1fe3cd3c3dd6be4fa0e213f287ca2b636c370b 100644 (file)
@@ -32,7 +32,6 @@ class DailyMailNotificationCronjob extends AbstractCronjob {
                parent::execute($cronjob);
                
                // get user ids
-               $userIDs = array();
                $sql = "SELECT  DISTINCT userID
                        FROM    wcf".WCF_N."_user_notification
                        WHERE   mailNotified = ?
@@ -44,9 +43,7 @@ class DailyMailNotificationCronjob extends AbstractCronjob {
                        TIME_NOW - 3600 * 23,
                        0
                ));
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                if (empty($userIDs)) return;
                
                // get users
index 5e8c04eae751a175d740e1335640c8a12bfca023..4171428aa6a1535c95bc1a7a132eaf226be03bdb 100644 (file)
@@ -32,10 +32,7 @@ class ModerationQueueCronjob extends AbstractCronjob {
                        ModerationQueue::STATUS_DONE,
                        (TIME_NOW - (86400 * 30))
                ));
-               $queueIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $queueIDs[] = $row['queueID'];
-               }
+               $queueIDs = $statement->fetchColumns();
                
                if (!empty($queueIDs)) {
                        $conditions = new PreparedStatementConditionBuilder();
index 445e98331411a4566c6d8df21f69ef32eb14bc2d..f65050eab27c6224a91c596abedfcda03cf4de78 100644 (file)
@@ -21,7 +21,6 @@ class UserQuitCronjob extends AbstractCronjob {
        public function execute(Cronjob $cronjob) {
                parent::execute($cronjob);
                
-               $userIDs = array();
                $sql = "SELECT  userID
                        FROM    wcf".WCF_N."_user
                        WHERE   quitStarted > ?
@@ -31,9 +30,7 @@ class UserQuitCronjob extends AbstractCronjob {
                        0,
                        (TIME_NOW - 7 * 24 * 3600)
                ));
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                if (!empty($userIDs)) {
                        $action = new UserAction($userIDs, 'delete');
index 9be0d7ce3e863117121c966892edbdb337c31927..7d39de6c8adeb80cdc58b19304a864b3fb871aaa 100644 (file)
@@ -159,6 +159,21 @@ class PreparedStatement {
                return $column;
        }
        
+       /**
+        * Returns a specific column for all of the remaining rows.
+        * 
+        * @param       integer         $columnNumber
+        * @return      array
+        */
+       public function fetchColumns($columnNumber = 0) {
+               $columns = [];
+               while ($column = $this->fetchColumn($columnNumber)) {
+                       $columns[] = $column;
+               }
+               
+               return $columns;
+       }
+       
        /**
         * Fetches the next row from a result set in a database object.
         * 
index 8aa0f280c5f0fd39ab7336bfc2f63e7db0f45edf..92de7cc17c03c0d57dc1f8a62e59ad6c23d6ca91 100644 (file)
@@ -133,10 +133,7 @@ class EditHistoryManager extends SingletonFactory {
                        $userIDs
                ));
                
-               $entryIDs = array();
-               while ($entryID = $statement->fetchColumn()) {
-                       $entryIDs[] = $entryID;
-               }
+               $entryIDs = $statement->fetchColumns();
                if (empty($entryIDs)) return;
                
                $list = new EditHistoryEntryList();
index 86ae1a002f4f678917b4b3732ef7c7250f824ac6..bcb05ec2925eaab5a709859b37f70a5cbff1afc3 100644 (file)
@@ -42,8 +42,7 @@ class AbstractCommentResponseImporter extends AbstractImporter {
                        ORDER BY        time ASC, responseID ASC";
                $statement = WCF::getDB()->prepareStatement($sql, 5);
                $statement->execute(array($response->commentID));
-               $responseIDs = array();
-               while ($responseID = $statement->fetchColumn()) $responseIDs[] = $responseID;
+               $responseIDs = $statement->fetchColumns();
                
                // update parent comment
                $sql = "UPDATE  wcf".WCF_N."_comment
index 123dbe78750a78da1427e56634d89e152d3e397e..7b91f835de66d625cfa81716de8a76d3a78a37a7 100644 (file)
@@ -49,9 +49,7 @@ class UserImporter extends AbstractImporter {
                        WHERE   preset = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array(1));
-               while ($row = $statement->fetchArray()) {
-                       $this->eventIDs[] = $row['eventID'];
-               }
+               $this->eventIDs = $statement->fetchColumns();
                
                $userOptionList = new UserOptionList();
                $userOptionList->readObjects();
index 09d756aabb935cfefe55f5140bc160238f408a92..be94ea047416782ee419b9df1fa454e01e34e90d 100644 (file)
@@ -89,10 +89,7 @@ abstract class AbstractModerationQueueHandler implements IModerationQueueHandler
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               $queueIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $queueIDs[] = $row['queueID'];
-               }
+               $queueIDs = $statement->fetchColumns();
                
                if (!empty($queueIDs)) {
                        $queueAction = new ModerationQueueAction($queueIDs, 'delete');
index 52649bcb92ba12ea518f02d648e44c2944672a52..d66ebbabbe15e107f6107e3f9dbe2dd70be72252 100644 (file)
@@ -464,7 +464,6 @@ class PackageInstallationScheduler {
                
                // get highest version of the required major release
                if (preg_match('/(\d+\.\d+\.)/', $version, $match)) {
-                       $packageVersions = array();
                        $sql = "SELECT  DISTINCT packageVersion
                                FROM    wcf".WCF_N."_package_update_version
                                WHERE   packageUpdateID IN (
@@ -478,9 +477,7 @@ class PackageInstallationScheduler {
                                $package->package,
                                $match[1].'%'
                        ));
-                       while ($row = $statement->fetchArray()) {
-                               $packageVersions[] = $row['packageVersion'];
-                       }
+                       $packageVersions = $statement->fetchColumns();
                        
                        if (count($packageVersions) > 1) {
                                // sort by version number
index b7a0edd6273d31d78191d1b286d7334db04593d1..efc2f2bc69d6496641f038e2cee888391c76f538 100644 (file)
@@ -345,10 +345,7 @@ class BoxPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                ".$conditionBuilder;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditionBuilder->getParameters());
-                       $pageIDs = [];
-                       while ($pageID = $statement->fetchColumn()) {
-                               $pageIDs[] = $pageID;
-                       }
+                       $pageIDs = $statement->fetchColumns();
                        
                        // save page ids
                        foreach ($pageIDs as $pageID) {
index 82cec96692ea14ce480187aacc4d1da0ac827fee..0ae8e847c0f653b52457ceb50becc29f132ed367 100644 (file)
@@ -258,10 +258,7 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                        " . $conditionBuilder;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditionBuilder->getParameters());
-                               $pageIDs = [];
-                               while ($row = $statement->fetchArray()) {
-                                       $pageIDs[] = $row['pageID'];
-                               }
+                               $pageIDs = $statement->fetchColumns();
                                
                                // save page ids
                                foreach ($pageIDs as $pageID) {
index 62a713c4c2eb0e540e48d550d719e409f2afb38a..0e390a87966c20c16ce5e01b7d513563a64ebb01 100644 (file)
@@ -623,15 +623,12 @@ class SessionHandler extends SingletonFactory {
                
                // work-around for setup process (package wcf does not exist yet)
                if (!PACKAGE_ID) {
-                       $groupIDs = array();
                        $sql = "SELECT  groupID
                                FROM    wcf".WCF_N."_user_to_group
                                WHERE   userID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute(array($this->user->userID));
-                       while ($row = $statement->fetchArray()) {
-                               $groupIDs[] = $row['groupID'];
-                       }
+                       $groupIDs = $statement->fetchColumns();
                }
                else {
                        $groupIDs = $this->user->getGroupIDs();
@@ -674,9 +671,7 @@ class SessionHandler extends SingletonFactory {
                                WHERE   userID = ?";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute(array($this->user->userID));
-                       while ($row = $statement->fetchArray()) {
-                               $this->languageIDs[] = $row['languageID'];
-                       }
+                       $this->languageIDs = $statement->fetchColumns();
                }
                else {
                        $this->languageIDs = $this->user->getLanguageIDs();
index ca554603240941575e4e9179afdd9f89bc673048..f5f28a51cc553240857e9432662532f2eb89309a 100644 (file)
@@ -102,9 +102,7 @@ class UserCollapsibleContentHandler extends SingletonFactory {
                                                $objectTypeID,
                                                WCF::getUser()->userID
                                        ));
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->collapsedContent[$objectTypeID][] = $row['objectID'];
-                                       }
+                                       $this->collapsedContent[$objectTypeID] = $statement->fetchColumns();
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'collapsedContent-'.$objectTypeID, serialize($this->collapsedContent[$objectTypeID]));
index 4729c6fa48f18d13edc87028f66d1c07f74f422f..15404ef42b0123fa1de88249de6f5314d692d76e 100644 (file)
@@ -156,10 +156,7 @@ class UserNotificationHandler extends SingletonFactory {
                                ".$conditions;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditions->getParameters());
-                       $notificationIDs = array();
-                       while ($row = $statement->fetchArray()) {
-                               $notificationIDs[] = $row['notificationID'];
-                       }
+                       $notificationIDs = $statement->fetchColumns();
                        
                        // filter array of existing notifications and remove values which
                        // do not have a notification from this author yet (inverse logic!)
@@ -709,11 +706,7 @@ class UserNotificationHandler extends SingletonFactory {
                $statement->execute(array(
                        $objectTypeObj->objectTypeID
                ));
-               
-               $eventIDs = array();
-               while ($row = $statement->fetchArray()) {
-                       $eventIDs[] = $row['eventID'];
-               }
+               $eventIDs = $statement->fetchColumns();
                
                if (!empty($eventIDs)) {
                        $conditions = new PreparedStatementConditionBuilder();
@@ -725,11 +718,7 @@ class UserNotificationHandler extends SingletonFactory {
                                ".$conditions;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditions->getParameters());
-                       
-                       $userIDs = array();
-                       while ($userID = $statement->fetchColumn()) {
-                               $userIDs[] = $userID;
-                       }
+                       $userIDs = $statement->fetchColumns();
                        
                        // reset number of notifications
                        if (!empty($userIDs)) {
index 884dc21266956dc4830a1bd08b58469daa5ed5f9..2869de50b19580c7d722ef647979c9655b8a806e 100644 (file)
@@ -30,8 +30,6 @@ trait TMultiRecipientModerationQueueCommentUserNotificationObjectType {
                        return [];
                }
                
-               $recipientIDs = [];
-               
                // 1. fetch assigned user
                // 2. fetch users who commented on the moderation queue entry
                // 3. fetch users who responded to a comment on the moderation queue entry
@@ -65,9 +63,7 @@ trait TMultiRecipientModerationQueueCommentUserNotificationObjectType {
                        $comment->objectID,
                        $objectTypeID
                ]);
-               while ($userID = $statement->fetchColumn()) {
-                       $recipientIDs[] = $userID;
-               }
+               $recipientIDs = $statement->fetchColumns();
                
                // make sure that all users can (still) access the moderation queue entry
                if (!empty($recipientIDs)) {
@@ -80,11 +76,7 @@ trait TMultiRecipientModerationQueueCommentUserNotificationObjectType {
                                ".$conditionBuilder;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditionBuilder->getParameters());
-                       
-                       $recipientIDs = [];
-                       while ($userID = $statement->fetchColumn()) {
-                               $recipientIDs[] = $userID;
-                       }
+                       $recipientIDs = $statement->fetchColumns();
                        
                        // make sure that all users (still) have permission to access moderation
                        if (!$recipientIDs) {
index 4a3973b7127cc6f446780050701d019cd1b1255b..23b2ccfddbec02c7215a92c3caf93f9e5260d8a4 100644 (file)
@@ -53,7 +53,6 @@ class UserObjectWatchHandler extends SingletonFactory {
                $objectTypeObj = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.objectWatch', $objectType);
                
                // get subscriber
-               $userIDs = array();
                $conditionsBuilder = new PreparedStatementConditionBuilder();
                $conditionsBuilder->add('objectTypeID = ?', array($objectTypeObj->objectTypeID));
                $conditionsBuilder->add('objectID IN (?)', array($objectIDs));
@@ -62,9 +61,7 @@ class UserObjectWatchHandler extends SingletonFactory {
                        ".$conditionsBuilder;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionsBuilder->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $userIDs[] = $row['userID'];
-               }
+               $userIDs = $statement->fetchColumns();
                
                if (!empty($userIDs)) {
                        // reset user storage