Add `PreparedStatement::fetchMap()` method
authorMatthias Schmidt <gravatronics@live.com>
Sun, 17 Jul 2016 17:56:30 +0000 (19:56 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 17 Jul 2016 17:56:30 +0000 (19:56 +0200)
32 files changed:
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php
wcfsetup/install/files/lib/acp/page/UserListPage.class.php
wcfsetup/install/files/lib/data/comment/response/LikeableCommentResponseProvider.class.php
wcfsetup/install/files/lib/data/option/OptionEditor.class.php
wcfsetup/install/files/lib/data/package/update/PackageUpdateAction.class.php
wcfsetup/install/files/lib/data/poll/PollAction.class.php
wcfsetup/install/files/lib/data/style/StyleEditor.class.php
wcfsetup/install/files/lib/data/user/group/UserGroup.class.php
wcfsetup/install/files/lib/data/user/group/UserGroupAction.class.php
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/acl/ACLHandler.class.php
wcfsetup/install/files/lib/system/bulk/processing/user/AbstractUserBulkProcessingAction.class.php
wcfsetup/install/files/lib/system/cache/builder/ClipboardPageCacheBuilder.class.php
wcfsetup/install/files/lib/system/cache/builder/TagCloudCacheBuilder.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php
wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php
wcfsetup/install/files/lib/system/importer/AbstractACLImporter.class.php
wcfsetup/install/files/lib/system/label/LabelHandler.class.php
wcfsetup/install/files/lib/system/language/I18nHandler.class.php
wcfsetup/install/files/lib/system/package/ACPTemplatesFileHandler.class.php
wcfsetup/install/files/lib/system/package/FilesFileHandler.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationSQLParser.class.php
wcfsetup/install/files/lib/system/package/TemplatesFileHandler.class.php
wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php
wcfsetup/install/files/lib/system/visitTracker/VisitTracker.class.php
wcfsetup/install/files/lib/system/worker/ArticleRebuildDataWorker.class.php
wcfsetup/install/files/lib/system/worker/LikeUserRebuildDataWorker.class.php

index a06387b8526a5f699e6cfa2345f328bfd861cf98..3076c7eeafd56765f317608dc98d3b65363696dc 100644 (file)
@@ -497,9 +497,7 @@ class StyleAddForm extends AbstractForm {
                        FROM    wcf".WCF_N."_style_variable";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $this->variables[$row['variableName']] = $row['defaultValue'];
-               }
+               $this->variables = $statement->fetchMap('variableName', 'defaultValue');
        }
        
        /**
index 219a9e5cd18607f13674443e344d18461fdd4e59..cb39ac858056f5d8b0cd7c116cd0e962dc2ba559 100755 (executable)
@@ -126,11 +126,7 @@ class UserAssignToGroupForm extends AbstractForm {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               
-               $groups = [];
-               while ($row = $statement->fetchArray()) {
-                       $groups[$row['userID']][] = $row['groupID'];
-               }
+               $groups = $statement->fetchMap('userID', 'groupID', false);
                
                foreach ($this->users as $user) {
                        if (!UserGroup::isAccessibleGroup($groups[$user->userID])) {
index 90938988b1d0741349c31770501751e95223354a..64d30ab06aeb8d6acb5869f6fe3caa6b4b643828 100644 (file)
@@ -207,9 +207,7 @@ class UserGroupOptionForm extends AbstractForm {
                                ".$conditions;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditions->getParameters());
-                       while ($row = $statement->fetchArray()) {
-                               $this->values[$row['groupID']] = $row['optionValue'];
-                       }
+                       $this->values = $statement->fetchMap('groupID', 'optionValue');
                }
                
                // create form elements for each group
index 73fca7e944f67a5250bf30d4c5a9d58ca9c9027d..3cddaddc7a072330e6973f8c18f96d6cf3d9fb91 100755 (executable)
@@ -243,8 +243,6 @@ class UserListPage extends SortablePage {
                
                // get user data
                if (!empty($userIDs)) {
-                       $userToGroups = [];
-                       
                        // get group ids
                        $conditions = new PreparedStatementConditionBuilder();
                        $conditions->add("user_table.userID IN (?)", [$userIDs]);
@@ -254,9 +252,7 @@ class UserListPage extends SortablePage {
                                ".$conditions;
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute($conditions->getParameters());
-                       while ($row = $statement->fetchArray()) {
-                               $userToGroups[$row['userID']][] = $row['groupID'];
-                       }
+                       $userToGroups = $statement->fetchMap('userID', 'groupID', false);
                        
                        $sql = "SELECT          user_avatar.*, option_value.*, user_table.*
                                FROM            wcf".WCF_N."_user user_table
index 046caa3b99079f15bac4e78753591a9f1a00e201..910bf0664a2ef25a6856bcf62fd948d85e71ee4b 100644 (file)
@@ -62,7 +62,6 @@ class LikeableCommentResponseProvider extends AbstractObjectTypeProvider impleme
                }
                
                // get objects type ids
-               $responses = [];
                $conditionBuilder = new PreparedStatementConditionBuilder();
                $conditionBuilder->add('comment_response.responseID IN (?)', [$responseIDs]);
                $sql = "SELECT          comment.objectTypeID, comment_response.responseID
@@ -72,9 +71,7 @@ class LikeableCommentResponseProvider extends AbstractObjectTypeProvider impleme
                        ".$conditionBuilder;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
-               while ($row = $statement->fetchArray()) {
-                       $responses[$row['responseID']] = $row['objectTypeID'];
-               }
+               $responses = $statement->fetchMap('responseID', 'objectTypeID');
                
                // group likes by object type id
                $likeData = [];
index 70b7d4d1d9e7a4c2e3935850da570882d79c3b34..6b94b8e14eeef18e7d0a6f28b5c571a85012fdb0 100644 (file)
@@ -42,10 +42,7 @@ class OptionEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        FROM            wcf".WCF_N."_option";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $optionIDs = [];
-               while ($row = $statement->fetchArray()) {
-                       $optionIDs[$row['optionName']] = $row['optionID'];
-               }
+               $optionIDs = $statement->fetchMap('optionName', 'optionID');
                
                $newOptions = [];
                foreach ($options as $name => $value) {
index 5fcbe76bce3eb62219cf929a8f552537dbeb0991..c70b8952c527b17e48b581f4442726b9af274b2d 100644 (file)
@@ -150,10 +150,7 @@ class PackageUpdateAction extends AbstractDatabaseObjectAction {
                        FROM    wcf".WCF_N."_package";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               $installedPackages = [];
-               while ($row = $statement->fetchArray()) {
-                       $installedPackages[$row['package']] = $row['packageVersion'];
-               }
+               $installedPackages = $statement->fetchMap('package', 'packageVersion');
                
                // filter by version
                $conditions = new PreparedStatementConditionBuilder();
index 15cfe22264be933c07e2b428048d536e9faa9bab..cd2710b175cd16209fa5eebddf5197f34a148c39 100644 (file)
@@ -281,14 +281,7 @@ class PollAction extends AbstractDatabaseObjectAction implements IGroupedUserLis
                        WHERE   pollID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->poll->pollID]);
-               $voteData = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($voteData[$row['optionID']])) {
-                               $voteData[$row['optionID']] = [];
-                       }
-                       
-                       $voteData[$row['optionID']][] = $row['userID'];
-               }
+               $voteData = $statement->fetchMap('optionID', 'userID', false);
                
                // assign user ids
                foreach ($voteData as $optionID => $userIDs) {
index 46ad6e6056423682070356ae9d394a9bcf37b7f3..0e0b6c8d1355b01d5bfc810388d11843ec39cdeb 100644 (file)
@@ -633,10 +633,7 @@ class StyleEditor extends DatabaseObjectEditor implements IEditableCachedObject
                        WHERE           language_item.languageItem = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->styleDescription]);
-               $styleDescriptions = [];
-               while ($row = $statement->fetchArray()) {
-                       $styleDescriptions[$row['languageCode']] = $row['languageItemValue'];
-               }
+               $styleDescriptions = $statement->fetchMap('languageCode', 'languageItemValue');
                
                // create style info file
                $xml = new XMLWriter();
index ebf479c43fbe634c510d054a030a9e53d93bbbac..0676369ea04cc2d52f60b4aa1e2167491e8c5265 100644 (file)
@@ -351,16 +351,13 @@ class UserGroup extends DatabaseObject implements ITitledObject {
        public function getGroupOption($name) {
                if ($this->groupOptions === null) {
                        // get all options and filter options with low priority
-                       $this->groupOptions = $groupOptionIDs = [];
+                       $this->groupOptions = [];
                        
                        $sql = "SELECT          optionName, optionID
                                FROM            wcf".WCF_N."_user_group_option";
                        $statement = WCF::getDB()->prepareStatement($sql);
                        $statement->execute();
-                       
-                       while ($row = $statement->fetchArray()) {
-                               $groupOptionIDs[$row['optionName']] = $row['optionID'];
-                       }
+                       $groupOptionIDs = $statement->fetchMap('optionName', 'optionID');
                        
                        if (!empty($groupOptionIDs)) {
                                $conditions = new PreparedStatementConditionBuilder();
@@ -374,9 +371,7 @@ class UserGroup extends DatabaseObject implements ITitledObject {
                                        ".$conditions;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditions->getParameters());
-                               while ($row = $statement->fetchArray()) {
-                                       $this->groupOptions[$row['optionName']] = $row['optionValue'];
-                               }
+                               $this->groupOptions = $statement->fetchMap('optionName', 'optionValue');
                        }
                }
                
index 6c3bd6c9439219a24074918b7bbe6dc6da52cd77..105b3fff805e605da092e3542417af1db2e17563 100644 (file)
@@ -118,10 +118,7 @@ class UserGroupAction extends AbstractDatabaseObjectAction {
                        $statement->execute();
                }
                
-               $optionValues = [];
-               while ($row = $statement->fetchArray()) {
-                       $optionValues[$row['optionID']] = $row['optionValue'];
-               }
+               $optionValues = $statement->fetchMap('optionID', 'optionValue');
                
                $groupAction = new UserGroupAction([], 'create', [
                        'data' => [
index d453edcc656b6efcf4510c8a6717f599360c72f7..6871c272c16aac983d1165095293e6ab53777468 100644 (file)
@@ -1127,10 +1127,7 @@ class WCFSetup extends WCF {
                                        FROM    wcf".WCF_N."_package_installation_queue";
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute();
-                               $queues = [];
-                               while ($row = $statement->fetchArray()) {
-                                       $queues[$row['queueID']] = $row['parentQueueID'];
-                               }
+                               $queues = $statement->fetchMap('queueID', 'parentQueueID');
                                
                                $queueIDs = [];
                                /** @noinspection PhpUndefinedVariableInspection */
index b1d80e2d76340ac1eb27cbef4d058a994e57d545..a1160d628ad0e27e0281d069e7196fead3dffce0 100644 (file)
@@ -351,10 +351,7 @@ class ACLHandler extends SingletonFactory {
                                                ".$conditions;
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute($conditions->getParameters());
-                                       
-                                       while ($row = $statement->fetchArray()) {
-                                               $data['user']['label'][$row['userID']] = $row['username'];
-                                       }
+                                       $data['user']['label'] = $statement->fetchMap('userID', 'username');
                                }
                        }
                }
index c617ab64cf349f33cca62fea952dfb5adc4196fa..381517f00f054fad0269cbce8a7505f4243b9197 100644 (file)
@@ -41,15 +41,7 @@ abstract class AbstractUserBulkProcessingAction extends AbstractBulkProcessingAc
                        ".$conditionBuilder;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditionBuilder->getParameters());
-               
-               $groupIDs = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($groupIDs[$row['userID']])) {
-                               $groupIDs[$row['userID']] = [];
-                       }
-                       
-                       $groupIDs[$row['userID']][] = $row['groupID'];
-               }
+               $groupIDs = $statement->fetchMap('userID', 'groupID', false);
                
                $users = [];
                foreach ($userList as $user) {
index 3703b1984808422327391b5f35f5cbdcc936f3f8..0992fa5ca7b7b33c5032b3bc325d35761b853940 100644 (file)
@@ -20,15 +20,6 @@ class ClipboardPageCacheBuilder extends AbstractCacheBuilder {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
                
-               $data = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($data[$row['pageClassName']])) {
-                               $data[$row['pageClassName']] = [];
-                       }
-                       
-                       $data[$row['pageClassName']][] = $row['actionID'];
-               }
-               
-               return $data;
+               return $statement->fetchMap('pageClassName', 'actionID', false);
        }
 }
index 67855b992f823bcac2d7cd266b8499b7cb1bd6f2..cd2ab3393169236eba8f88e2167f51ac441c4741 100644 (file)
@@ -80,7 +80,6 @@ class TagCloudCacheBuilder extends AbstractCacheBuilder {
                
                if (!empty($this->objectTypeIDs)) {
                        // get tag ids
-                       $tagIDs = [];
                        $conditionBuilder = new PreparedStatementConditionBuilder();
                        $conditionBuilder->add('object.objectTypeID IN (?)', [$this->objectTypeIDs]);
                        $conditionBuilder->add('object.languageID IN (?)', [$this->languageIDs]);
@@ -91,9 +90,7 @@ class TagCloudCacheBuilder extends AbstractCacheBuilder {
                                ORDER BY        counter DESC";
                        $statement = WCF::getDB()->prepareStatement($sql, 500);
                        $statement->execute($conditionBuilder->getParameters());
-                       while ($row = $statement->fetchArray()) {
-                               $tagIDs[$row['tagID']] = $row['counter'];
-                       }
+                       $tagIDs = $statement->fetchMap('tagID', 'counter');
                        
                        // get tags
                        if (!empty($tagIDs)) {
index d4e42ac9ba79a956d10ff6512dc33ad2552778a1..32725f05f0eff95637e5908059dc6c495e56f5da 100644 (file)
@@ -141,14 +141,7 @@ class UserClipboardAction extends AbstractClipboardAction {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
                
-               $userToGroup = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($userToGroup[$row['userID']])) {
-                               $userToGroup[$row['userID']] = [];
-                       }
-                       
-                       $userToGroup[$row['userID']][] = $row['groupID'];
-               }
+               $userToGroup = $statement->fetchMap('userID', 'groupID', false);
                
                // validate if user's group is accessible for current user
                foreach ($userIDs as $userID) {
index ade6ffac60690afe3d5c0d042363cfba9fd2456c..d0d2f70474ba421b34036d3f174e4488673a415a 100644 (file)
@@ -185,6 +185,36 @@ class PreparedStatement {
                return $objects;
        }
        
+       /**
+        * Returns a map of all fetched rows using one column as key and another column as value.
+        * 
+        * @param       string          $keyColumn      name of the key column
+        * @param       string          $valueColumn    name of the value column
+        * @param       boolean         $uniqueKey      if `true`, a one-dimensional array is returned, otherwise, for each key an array of fetched values is returned 
+        * @return      string[]|string[][]
+        */
+       public function fetchMap($keyColumn, $valueColumn, $uniqueKey = true) {
+               $map = [];
+               
+               while (($row = $this->fetchArray())) {
+                       $key = $row[$keyColumn];
+                       $value = $row[$valueColumn];
+                       
+                       if ($uniqueKey) {
+                               $map[$key] = $value;
+                       }
+                       else {
+                               if (!isset($map[$key])) {
+                                       $map[$key] = [];
+                               }
+                               
+                               $map[$key][] = $value;
+                       }
+               }
+               
+               return $map;
+       }
+       
        /**
         * Counts number of affected rows by the last sql statement (INSERT, UPDATE or DELETE).
         * 
index 3052c16d24f7533bc7b3e4aeeb967c53769a1a9b..818fc04f4ad942f531555f06833a031ac64af553 100644 (file)
@@ -236,11 +236,7 @@ class HtmlInputNodeTextParser {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               
-               $users = [];
-               while ($row = $statement->fetchArray()) {
-                       $users[$row['userID']] = $row['username'];
-               }
+               $users = $statement->fetchMap('userID', 'username');
                
                // sort usernames with the longest one being first
                uasort($users, function($a, $b) {
index 688ffacff93b916ba63fdc4168e2a1af3b900a54..3e5a32552cf97c92770e316d97dbc589b3ed16f8 100644 (file)
@@ -39,9 +39,7 @@ class AbstractACLImporter extends AbstractImporter {
                        WHERE   objectTypeID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->objectTypeID]);
-               while ($row = $statement->fetchArray()) {
-                       $this->options[$row['optionName']] = $row['optionID'];
-               }
+               $this->options = $statement->fetchMap('optionName', 'optionID');
        }
        
        /**
index 957884271da6df67a6d9bd8e651fe0278cbbefb1..bef973e676327520585096d7141d5a080d1d693f 100644 (file)
@@ -210,15 +210,7 @@ class LabelHandler extends SingletonFactory {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               
-               $labels = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($labels[$row['labelID']])) {
-                               $labels[$row['labelID']] = [];
-                       }
-                       
-                       $labels[$row['labelID']][] = $row['objectID'];
-               }
+               $labels = $statement->fetchMap('labelID', 'objectID', false);
                
                // optionally filter out labels without permissions
                if ($validatePermissions) {
index 51e1ee21aa1f8d18ad45e3467b23d34a30891464..e9a90dccaf119ec86c98ed185e69dbef1b618826 100644 (file)
@@ -284,10 +284,7 @@ class I18nHandler extends SingletonFactory {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               $languageItemIDs = [];
-               while ($row = $statement->fetchArray()) {
-                       $languageItemIDs[$row['languageID']] = $row['languageItemID'];
-               }
+               $languageItemIDs = $statement->fetchMap('languageID', 'languageItemID');
                
                $insertLanguageIDs = $updateLanguageIDs = [];
                foreach ($languageIDs as $languageID) {
index 678bf555c5723fc2cc0db7c2a03d2ca77bbca409..a62f3aecd9a2f6696ee9d90b9d9264058e6ad475 100644 (file)
@@ -52,11 +52,7 @@ class ACPTemplatesFileHandler extends PackageInstallationFileHandler {
                                        ".$conditions;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditions->getParameters());
-                               
-                               $lockedFiles = [];
-                               while ($row = $statement->fetchArray()) {
-                                       $lockedFiles[$row['templateName']] = $row['packageID'];
-                               }
+                               $lockedFiles = $statement->fetchMap('templateName', 'packageID');
                                
                                // check if acp templates from the package beeing
                                // installed are in conflict with already installed
index 86f9d44e39af57224a3004c91fcbcc1b02d44356..dab7686603a9375bc3ea6259898324f71719e32b 100644 (file)
@@ -32,10 +32,7 @@ class FilesFileHandler extends PackageInstallationFileHandler {
                                        ".$conditions;
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute($conditions->getParameters());
-                               $lockedFiles = [];
-                               while ($row = $statement->fetchArray()) {
-                                       $lockedFiles[$row['filename']] = $row['packageID'];
-                               }
+                               $lockedFiles = $statement->fetchMap('filename', 'packageID');
                                
                                // check delivered files
                                if (!empty($lockedFiles)) {
index a7acbc1f43e489740e396075631f3ba9a4b323ca..7397993940905eee0c75d812d9bbd10d017562ce 100644 (file)
@@ -199,9 +199,7 @@ class PackageInstallationSQLParser extends SQLParser {
                                AND sqlIndex = ''";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute();
-               while ($row = $statement->fetchArray()) {
-                       $this->knownTables[$row['sqlTable']] = $row['packageID'];
-               }
+               $this->knownTables = $statement->fetchMap('sqlTable', 'packageID');
        }
        
        /**
index aa17970c532875188153858392e6cfe85826f106..8503bddca562550cafa76befb23b20b39642d9f2 100644 (file)
@@ -35,7 +35,7 @@ class TemplatesFileHandler extends ACPTemplatesFileHandler {
                unset($file);
                
                // get existing templates
-               $existingTemplates = $updateTemplateIDs = [];
+               $updateTemplateIDs = [];
                $sql = "SELECT  templateName, templateID
                        FROM    wcf".WCF_N."_template
                        WHERE   packageID = ?
@@ -43,9 +43,7 @@ class TemplatesFileHandler extends ACPTemplatesFileHandler {
                                AND templateGroupID IS NULL";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$packageID, $this->application]);
-               while ($row = $statement->fetchArray()) {
-                       $existingTemplates[$row['templateName']] = $row['templateID'];
-               }
+               $existingTemplates = $statement->fetchMap('templateName', 'templateID');
                
                // save new templates
                $sql = "INSERT INTO     wcf".WCF_N."_template
index 49ba49bfe7bb86167eea24404c4beabcbe224a19..51e5f1d1e3160731ee08df9b9a20a16061e00722 100644 (file)
@@ -88,15 +88,7 @@ class FilePackageInstallationPlugin extends AbstractPackageInstallationPlugin {
                        WHERE   packageID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$this->installation->getPackageID()]);
-               
-               $files = [];
-               while ($row = $statement->fetchArray()) {
-                       if (!isset($files[$row['application']])) {
-                               $files[$row['application']] = [];
-                       }
-                       
-                       $files[$row['application']][] = $row['filename'];
-               }
+               $files = $statement->fetchMap('application', 'filename', false);
                
                foreach ($files as $application => $filenames) {
                        /** @noinspection PhpUndefinedMethodInspection */
index b4c05ceabba44b5477ba41d1be2710cdf08842a8..e68142d734b871570b27d58d59f285576d83cb86 100644 (file)
@@ -41,10 +41,7 @@ class MenuItemACPSearchResultProvider extends AbstractACPSearchResultProvider im
                        ORDER BY        languageItemValue ASC";
                $statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
                $statement->execute($conditions->getParameters());
-               $languageItems = [];
-               while ($row = $statement->fetchArray()) {
-                       $languageItems[$row['languageItem']] = $row['languageItemValue'];
-               }
+               $languageItems = $statement->fetchMap('languageItem', 'languageItemValue');
                
                if (empty($languageItems)) {
                        return [];
index acd49aaa4588e8feb20a4696ed639e30763db14e..03d58838d068affce058095018b83545c9507a58 100644 (file)
@@ -133,10 +133,7 @@ class UserNotificationHandler extends SingletonFactory {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               $notifications = [];
-               while ($row = $statement->fetchArray()) {
-                       $notifications[$row['userID']] = $row['notificationID'];
-               }
+               $notifications = $statement->fetchMap('userID', 'notificationID');
                
                // check if event supports stacking and author should be added
                if (!empty($notifications) && $event->isStackable()) {
index 0c44b4c5f871056dcbd0da6a0ad0b4a522da5cec..b0592d5cfcbff99868d3c5a7f7de40da19044ae3 100644 (file)
@@ -71,15 +71,12 @@ class VisitTracker extends SingletonFactory {
                                
                                // cache does not exist or is outdated
                                if ($data === null) {
-                                       $this->userVisits = [];
                                        $sql = "SELECT  objectTypeID, visitTime
                                                FROM    wcf".WCF_N."_tracked_visit_type
                                                WHERE   userID = ?";
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        $statement->execute([WCF::getUser()->userID]);
-                                       while ($row = $statement->fetchArray()) {
-                                               $this->userVisits[$row['objectTypeID']] = $row['visitTime'];
-                                       }
+                                       $this->userVisits = $statement->fetchMap('objectTypeID', 'visitTime');
                                        
                                        // update storage data
                                        UserStorageHandler::getInstance()->update(WCF::getUser()->userID, 'trackedUserVisits', serialize($this->userVisits));
index 681ae73450ca463e5335b3eced34a04fb6a28151..40e5d86f70bb47641378a26a272567451eb5a5bb 100644 (file)
@@ -86,12 +86,7 @@ class ArticleRebuildDataWorker extends AbstractRebuildDataWorker {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               $cumulativeLikes = [];
-               
-               /** @noinspection PhpAssignmentInConditionInspection */
-               while ($row = $statement->fetchArray()) {
-                       $cumulativeLikes[$row['objectID']] = $row['cumulativeLikes'];
-               }
+               $cumulativeLikes = $statement->fetchMap('objectID', 'cumulativeLikes');
                
                foreach ($this->objectList as $article) {
                        $editor = new ArticleEditor($article);
index 52f804e54453f648bca53375c8ab6c25350d95b9..4c598280ff4c1a208e6dbfa1b02bae0eacb70289 100644 (file)
@@ -81,10 +81,7 @@ class LikeUserRebuildDataWorker extends AbstractRebuildDataWorker {
                        ".$conditions;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute($conditions->getParameters());
-               $usernames = [];
-               while ($row = $statement->fetchArray()) {
-                       $usernames[$row['userID']] = $row['username'];
-               }
+               $usernames = $statement->fetchMap('userID', 'username');
                
                // update like objects
                $sql = "UPDATE  wcf".WCF_N."_like_object