From ffd36c80391ef321863fb69dc90303fdf597022a Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 26 Jun 2008 10:02:34 -0400 Subject: [PATCH] Change while($o = $db->fetch_array($r)) to foreach($r as $o) --- admin/automation.php | 4 ++-- admin/field.php | 6 +++--- admin/language.php | 2 +- admin/permission.php | 6 +++--- admin/priority.php | 2 +- admin/product.php | 6 +++--- admin/resolution.php | 2 +- admin/severity.php | 2 +- admin/status.php | 2 +- admin/user.php | 6 +++--- admin/usergroup.php | 14 +++++++------- admin/userhelp.php | 2 +- attachment.php | 2 +- docs/datatools.php | 4 ++-- docs/migrate_custom_fields.php | 4 ++-- docs/update_bug_names.php | 4 ++-- docs/update_bug_table_cache.php | 2 +- docs/update_field_order_in_bugs.php | 6 +++--- docs/update_history.php | 2 +- explain.php | 2 +- favorite.php | 2 +- includes/class_notification.php | 10 +++++----- includes/functions.php | 4 ++-- includes/functions_datastore.php | 28 ++++++++++++++-------------- install/convert_database_charset.php | 2 +- install/upgrade11.php | 4 ++-- install/upgrade2.php | 8 ++++---- search.php | 14 +++++++------- showhistory.php | 4 ++-- showreport.php | 10 +++++----- syndicate.php | 2 +- userctrl.php | 4 ++-- 32 files changed, 86 insertions(+), 86 deletions(-) diff --git a/admin/automation.php b/admin/automation.php index 5d1ea04..3f6509b 100644 --- a/admin/automation.php +++ b/admin/automation.php @@ -170,7 +170,7 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') // ------------------------------------------------------------------- // custom fields $fields_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid ASC"); - while ($field = $db->fetch_array($fields_fetch)) + foreach ($fields_fetch as $field) { switch ($field['type']) { @@ -220,7 +220,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_head(T('Automations')); $actions = $db->query("SELECT * FROM " . TABLE_PREFIX . "automation ORDER BY name ASC"); - while ($action = $db->fetch_array($actions)) + foreach ($actions as $action) { $admin->row_text($action['name'] . "\n
$action[description]
", "[" . T('Edit') . "] [" . T('Delete') . "]"); } diff --git a/admin/field.php b/admin/field.php index c27f40c..2ebb761 100644 --- a/admin/field.php +++ b/admin/field.php @@ -246,14 +246,14 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit') if ($edit) { $perms = $db->query("SELECT usergroupid, mask FROM " . TABLE_PREFIX . "bugfieldpermission WHERE fieldid = " . $field->objdata['fieldid']); - while ($perm = $db->fetch_array($perms)) + foreach ($perms as $perm) { $permissions["$perm[usergroupid]"] = $perm['mask']; } } $usergroups = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid"); - while ($usergroup = $db->fetch_array($usergroups)) + foreach ($usergroups as $usergroup) { unset($listitem); $admin->list_item(T('No Permission'), 0, $permissions["$usergroup[usergroupid]"] == 0); @@ -288,7 +288,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_column_head(array(T('Display Name/Description'), T('Field ID'), T('Actions'))); $fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid ASC"); - while ($field = $db->fetch_array($fields)) + foreach ($fields as $field) { $admin->row_multi_item( array( diff --git a/admin/language.php b/admin/language.php index 237a902..9d813d8 100644 --- a/admin/language.php +++ b/admin/language.php @@ -171,7 +171,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_column_head(array(T('Title'), T('Language Code / Charset'), T('Options'))); $languages = $db->query("SELECT * FROM " . TABLE_PREFIX . "language ORDER BY languageid ASC"); - while ($language = $db->fetch_array($languages)) + foreach ($languages as $language) { $admin->row_multi_item(array( "$language[title]" => 'l', diff --git a/admin/permission.php b/admin/permission.php index 43ffea9..a0d1208 100755 --- a/admin/permission.php +++ b/admin/permission.php @@ -181,7 +181,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_head(T('Permission Manager')); $groups = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid ASC"); - while ($group = $db->fetch_array($groups)) + foreach ($groups as $group) { $usergroups["$group[usergroupid]"] = $group; } @@ -194,13 +194,13 @@ if ($_REQUEST['do'] == 'modify') if ($bugsys->in['usergroupid'] == $group['usergroupid']) { $permissions_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "permission WHERE usergroupid = $group[usergroupid]"); - while ($permission = $db->fetch_array($permissions_fetch)) + foreach ($permissions_fetch as $permission) { $permissions["$permission[productid]"] = $permission['mask']; } $products_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE !parentid OR parentid IS NULL ORDER BY displayorder ASC"); - while ($product = $db->fetch_array($products_fetch)) + foreach ($products_fetch as $product) { $groupid = $group['usergroupid']; $prodid = $product['productid']; diff --git a/admin/priority.php b/admin/priority.php index 93bc424..7da2551 100755 --- a/admin/priority.php +++ b/admin/priority.php @@ -148,7 +148,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_start(); $admin->table_head(T('Priority Manager')); - while ($priority = $db->fetch_array($priorities)) + foreach ($priorities as $priority) { $admin->row_text("$priority[displayorder]: $priority[priority]", "(priorityid: $priority[priorityid]) [" . T('Edit') . "] [" . T('Delete') . "]"); } diff --git a/admin/product.php b/admin/product.php index 82705fd..5f13e3d 100755 --- a/admin/product.php +++ b/admin/product.php @@ -187,7 +187,7 @@ if ($_REQUEST['do'] == 'killproduct') { $bugsys->input_clean('productid', TYPE_UINT); $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = " . $bugsys->in['productid'] . " OR parentid = " . $bugsys->in['productid']); - while ($prod = $db->fetch_array($allprods)) + foreach ($allprods as $prod) { $list[] = $prod['productid']; } @@ -357,7 +357,7 @@ EOF; $products_get = $db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); $products = array(); - while ($prod = $db->fetch_array($products_get)) + foreach ($products_get as $prod) { if (!$prod['parentid']) { @@ -372,7 +372,7 @@ EOF; $versions_get = $db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC"); $versions = array(); - while ($vers = $db->fetch_array($versions_get)) + foreach ($versions_get as $vers) { $versions["$vers[productid]"]["$vers[versionid]"] = $vers; } diff --git a/admin/resolution.php b/admin/resolution.php index 1f8d389..514709f 100755 --- a/admin/resolution.php +++ b/admin/resolution.php @@ -148,7 +148,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_start(); $admin->table_head(T('Resolution Manager')); - while ($resolution = $db->fetch_array($resolutions)) + foreach ($resolutions as $resolution) { $admin->row_text("$resolution[displayorder]: $resolution[resolution]", "(resolutionid: $resolution[resolutionid]) [" . T('Edit') . "] [" . T('Delete') . "]"); } diff --git a/admin/severity.php b/admin/severity.php index 6b7aa7e..abdf148 100755 --- a/admin/severity.php +++ b/admin/severity.php @@ -148,7 +148,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_start(); $admin->table_head(T('Severity Manager')); - while ($severity = $db->fetch_array($severities)) + foreach ($severities as $severity) { $admin->row_text("$severity[displayorder]: $severity[severity]", "(severityid: $severity[severityid]) [" . T('Edit') . "] [" . T('Delete') . "]"); } diff --git a/admin/status.php b/admin/status.php index 88ea3cd..3d2a7ab 100755 --- a/admin/status.php +++ b/admin/status.php @@ -151,7 +151,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_start(); $admin->table_head(T('Status Manager')); - while ($status = $db->fetch_array($statuses)) + foreach ($statuses as $status) { $colorblock = '
'; $admin->row_text("$colorblock$status[displayorder]: $status[status]", "(statusid: $status[statusid]) [" . T('Edit') . "] [" . T('Delete') . "]"); diff --git a/admin/user.php b/admin/user.php index 1995f96..13ff1d7 100644 --- a/admin/user.php +++ b/admin/user.php @@ -242,7 +242,7 @@ if ($_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == 'add') if ($user->objdata['userid']) { $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $user->objdata['userid']); - while ($opt = $db->fetch_array($options)) + foreach ($options as $opt) { foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) { @@ -357,7 +357,7 @@ if ($_REQUEST['do'] == 'search') $admin->table_head(T('Search Results'), 4); $admin->table_column_head(array(T('Display Name'), T('Email'), T('User ID'), T('Actions'))); - while ($row = $db->fetch_array($results)) + foreach ($results as $row) { $admin->row_multi_item(array( $row['displayname'] => 'l', @@ -400,7 +400,7 @@ if ($_REQUEST['do'] == 'showall') $pagination->splitPages(); $users = $db->query("SELECT * FROM " . TABLE_PREFIX . "user ORDER BY userid ASC LIMIT " . $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()); - while ($user = $db->fetch_array($users)) + foreach ($users as $user) { $admin->row_multi_item(array( $user['displayname'] => 'l', diff --git a/admin/usergroup.php b/admin/usergroup.php index 45dac27..3f0bc58 100755 --- a/admin/usergroup.php +++ b/admin/usergroup.php @@ -181,14 +181,14 @@ if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit' OR $_REQUEST['do'] == if ($edit OR $clone) { $perms = $db->query("SELECT fieldid, mask FROM " . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid = " . $usergroup->objdata['usergroupid']); - while ($perm = $db->fetch_array($perms)) + foreach ($perms as $perm) { $permissions["$perm[fieldid]"] = $perm['mask']; } } $fields = $db->query("SELECT fieldid, name FROM " . TABLE_PREFIX . "bugfield ORDER BY fieldid"); - while ($field = $db->fetch_array($fields)) + foreach ($fields as $field) { unset($listitem); $admin->list_item(T('No Permission'), 0, $permissions["$field[fieldid]"] == 0); @@ -249,7 +249,7 @@ if ($_POST['do'] == 'insert') if ($bugsys->input_clean('cloneid', TYPE_UINT)) { $prodperms = $db->query("SELECT * FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . $bugsys->in['cloneid']); - while ($prod = $db->fetch_array($prodperms)) + foreach ($prodperms as $prod) { $db->query("INSERT INTO " . TABLE_PREFIX . "permission (usergroupid, productid, mask) VALUES (" . $usergroup->insertid . ", $prod[productid], $prod[mask])"); } @@ -332,7 +332,7 @@ if ($_POST['do'] == 'doapprove') if (sizeof($idlist) > 0) { $users = $db->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid IN (" . implode(',', $idlist) . ")"); - while ($user = $db->fetch_array($users)) + foreach ($users as $user) { $tpl = $template->fetch(FetchEmailPath('accountapproved.xml', bugdar::$datastore['language'][bugdar::$options['defaultlanguage']]['langcode'])); eval('$email = "' . $tpl . '";'); @@ -364,7 +364,7 @@ if ($_REQUEST['do'] == 'approve') $admin->table_column_head(array(T('Display Name'), T('Usergroup'), T('Approve'))); $users = $db->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE usergroupid IN (3, 4)"); - while ($user = $db->fetch_array($users)) + foreach ($users as $user) { $admin->row_multi_item(array( '' . $user['email'] . '' => 'l', @@ -394,7 +394,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_head(T('Usergroup Manager'), 3, 'usergroups'); $groups = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup ORDER BY usergroupid ASC"); - while ($group = $db->fetch_array($groups)) + foreach ($groups as $group) { $usergroups["$group[usergroupid]"] = $group; } @@ -407,7 +407,7 @@ if ($_REQUEST['do'] == 'modify') GROUP BY usergroup.usergroupid ORDER BY usergroup.usergroupid" ); - while ($group = $db->fetch_array($groups)) + foreach ($groups as $group) { $usergroups["$group[usergroupid]"]['total'] = $group['total']; } diff --git a/admin/userhelp.php b/admin/userhelp.php index 5500055..b7c5b81 100755 --- a/admin/userhelp.php +++ b/admin/userhelp.php @@ -135,7 +135,7 @@ if ($_REQUEST['do'] == 'modify') $admin->table_head(T('Edit User Help')); $topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC"); - while ($topic = $db->fetch_array($topics)) + foreach ($topics as $topic) { $inputfield = ''; $delete = (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete()) ? '

[' . T('Delete') . ']' : ''); diff --git a/attachment.php b/attachment.php index 8392b48..b51ce83 100755 --- a/attachment.php +++ b/attachment.php @@ -179,7 +179,7 @@ if ($_REQUEST['do'] == 'add') $obsoletes_fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "attachment WHERE bugid = $bug[bugid] AND !obsolete"); $obsoletes = ''; - while ($obsolete = $db->fetch_array($obsoletes_fetch)) + foreach ($obsoletes_fetch as $obsolete) { $show['obsoletes'] = true; $obsoletes .= "
in['obsoletes']) AND in_array($obsolete['attachmentid'], $bugsys->in['obsoletes']) ? ' checked="checked"' : '') . " /> $obsolete[filename]" . ($obsolete['description'] ? " [$obsolete[description]]" : '') . "
\n"; diff --git a/docs/datatools.php b/docs/datatools.php index ab3be6e..e025d7a 100644 --- a/docs/datatools.php +++ b/docs/datatools.php @@ -63,7 +63,7 @@ if ($_REQUEST['do'] == 'export') foreach ($THELIST AS $display => $data) { $fetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "$data[table]" . (!$data['orderfree'] ? " ORDER BY {$data[table]}id ASC" : "")); - while ($fitem = $db->fetch_array($fetch)) + foreach ($fetch as $fitem) { $exportlist["$display"][] = $fitem; } @@ -198,7 +198,7 @@ if ($_REQUEST['do'] == 'settings') FILE; $settings = $db->query("SELECT * FROM " . TABLE_PREFIX . "setting"); - while ($setting = $db->fetch_array($settings)) + foreach ($settings as $setting) { $fout .= "\n\t'$setting[varname]' => '" . str_replace("'", "\'", $setting['value']) . "',"; } diff --git a/docs/migrate_custom_fields.php b/docs/migrate_custom_fields.php index 3385441..9738c10 100644 --- a/docs/migrate_custom_fields.php +++ b/docs/migrate_custom_fields.php @@ -8,14 +8,14 @@ require_once('global.php'); // gets all the fields $fields = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugfield"); -while ($field = $db->fetch_array($fields)) +foreach ($fields as $field) { // create the database field $db->query("ALTER TABLE " . TABLE_PREFIX . "bug ADD custom$field[fieldid] MEDIUMTEXT NULL"); // update all the data $data = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill"); - while ($custom = $db->fetch_array($data)) + foreach ($data as $custom) { $db->query("UPDATE " . TABLE_PREFIX . "bug SET custom$field[fieldid] = '" . $db->escape_string($custom["field$field[fieldid]"]) . "' WHERE bugid = $custom[bugid]"); } diff --git a/docs/update_bug_names.php b/docs/update_bug_names.php index 9e1a3a7..d33dc81 100644 --- a/docs/update_bug_names.php +++ b/docs/update_bug_names.php @@ -7,13 +7,13 @@ require_once('./global.php'); $userlist = array(); $users = $db->query("SELECT userid, displayname FROM " . TABLE_PREFIX . "user"); -while ($user = $db->fetch_array($users)) +foreach ($users as $user) { $userlist["$user[userid]"] = $user['displayname']; } $bugs = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug"); -while ($bug = $db->fetch_array($bugs)) +foreach ($bugs as $bug) { $db->query(" UPDATE " . TABLE_PREFIX . "bug diff --git a/docs/update_bug_table_cache.php b/docs/update_bug_table_cache.php index 87a5956..189feea 100644 --- a/docs/update_bug_table_cache.php +++ b/docs/update_bug_table_cache.php @@ -5,7 +5,7 @@ require_once('./global.php'); $comments = $db->query("SELECT * FROM " . TABLE_PREFIX . "comment ORDER BY bugid, dateline ASC"); -while ($comment = $db->fetch_array($comments)) +foreach ($comments as $comment) { if (!isset($replace["$comment[bugid]"])) { diff --git a/docs/update_field_order_in_bugs.php b/docs/update_field_order_in_bugs.php index 2f96280..0c47bb4 100644 --- a/docs/update_field_order_in_bugs.php +++ b/docs/update_field_order_in_bugs.php @@ -25,19 +25,19 @@ $fields = array( ); $bugs = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug"); -while ($bug = $db->fetch_array($bugs)) +foreach ($bugs as $bug) { $db->query("UPDATE " . TABLE_PREFIX . "bug SET priority = " . $fields['priority']["$bug[priority]"] . ", severity = " . $fields['severity']["$bug[severity]"] . " WHERE bugid = " . $bug['bugid']); } $severity = $db->query("SELECT * FROM " . TABLE_PREFIX . "severity"); -while ($thing = $db->fetch_array($severity)) +foreach ($severity as $thing) { $db->query("UPDATE " . TABLE_PREFIX . "severity SET severityid = " . rand(10, 100000) . " WHERE severityid = $thing[severityid]"); } $priority = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority"); -while ($thing = $db->fetch_array($priority)) +foreach ($priority as $thing) { $db->query("UPDATE " . TABLE_PREFIX . "priority SET priorityid = " . rand(10, 100000) . " WHERE priorityid = $thing[priorityid]"); } diff --git a/docs/update_history.php b/docs/update_history.php index f430944..13b53ef 100644 --- a/docs/update_history.php +++ b/docs/update_history.php @@ -10,7 +10,7 @@ require_once('./global.php'); $total = $nodo = 0; $history = $db->query("SELECT * FROM " . TABLE_PREFIX . "history"); -while ($log = $db->fetch_array($history)) +foreach ($history as $log) { $matches = array(); if (preg_match('#custom_field([0-9]+?)#i', $log['field'], $matches)) diff --git a/explain.php b/explain.php index 5c53d96..ebe272c 100644 --- a/explain.php +++ b/explain.php @@ -110,7 +110,7 @@ if ($_REQUEST['do'] == 'automations') AND permission.usergroupid IN ({bugdar::$userinfo['usergroupid']}" . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ") GROUP BY (bugfield.fieldid) "); - while ($field = $bugsys->db->fetch_array($fields_fetch)) + foreach ($fields_fetch as $field) { $fields["$field[fieldid]"] = $field; } diff --git a/favorite.php b/favorite.php index c10f6e7..c3fcf62 100644 --- a/favorite.php +++ b/favorite.php @@ -91,7 +91,7 @@ if ($_REQUEST['do'] == 'manage') $headers = $sort->constructColumnHeaders(false); - while ($bug = $db->fetch_array($favorites)) + foreach ($favorites as $bug) { $funct->exec_swap_bg('altcolor', ''); $bug = ProcessBugDataForDisplay($bug, $funct->bgcolour); diff --git a/includes/class_notification.php b/includes/class_notification.php index 2831a3c..8035803 100644 --- a/includes/class_notification.php +++ b/includes/class_notification.php @@ -154,13 +154,13 @@ class NotificationCenter function fetch_user_cache() { $newbuggers = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "useremail WHERE relation = " . $this->registry->emailoptions['relations']['-notapplicable-'] . " AND mask & " . $this->registry->emailoptions['notifications']['newbug']); - while ($newbug = $this->registry->db->fetch_array($newbuggers)) + foreach ($newbuggers as $newbug) { $this->roles['-notapplicable-']["$newbug[userid]"] = $newbug['userid']; } $favorites = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->registry->clean($this->bug['bugid'], TYPE_UINT)); - while ($fav = $this->registry->db->fetch_array($favorites)) + foreach ($favorites as $fav) { $this->roles['favorite']["$fav[userid]"] = $fav['userid']; } @@ -169,7 +169,7 @@ class NotificationCenter $this->roles['voter'] = preg_split('#,#', $voters['userids'], 0, PREG_SPLIT_NO_EMPTY); $commenters = $this->registry->db->query("SELECT userid FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->registry->clean($this->bug['bugid'], TYPE_UINT)); - while ($comment = $this->registry->db->fetch_array($commenters)) + foreach ($commenters as $comment) { $this->roles['commenter']["$comment[userid]"] = $comment['userid']; } @@ -186,7 +186,7 @@ class NotificationCenter ON (user.userid = useremail.userid) WHERE useremail.userid IN (" . implode(',', $masterids) . ") "); - while ($user = $this->registry->db->fetch_array($userinfo)) + foreach ($userinfo as $user) { if (!is_array($this->users["$user[userid]"])) { @@ -511,7 +511,7 @@ class NotificationCenter WHERE useremail.relation = 0 AND useremail.mask & " . $this->registry->emailoptions['notifications']['newbug'] . " "); - while ($userInfo = $this->registry->db->fetch_array($userinfo)) + foreach ($userinfo as $userInfo) { if (!is_array($this->users["$userInfo[userid]"])) { diff --git a/includes/functions.php b/includes/functions.php index 5bd5a43..79b8c4b 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -228,7 +228,7 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ") GROUP BY (bugfield.fieldid) "); - while ($field = $bugsys->db->fetch_array($fields_fetch)) + foreach ($fields_fetch as $field) { $fields["$field[fieldid]"] = $field; } @@ -379,7 +379,7 @@ function process_custom_fields(&$bugapi, &$msg, $errorbox = false, $searchMode = AND permission.usergroupid IN (" . bugdar::$userinfo['usergroupid'] . (sizeof(bugdar::$userinfo['groupids']) != 0 ? ',' . implode(',', bugdar::$userinfo['groupids']) : '') . ") GROUP BY (bugfield.fieldid) "); - while ($field = $bugsys->db->fetch_array($fields)) + foreach ($fields as $field) { $fieldname = "custom$field[fieldid]"; diff --git a/includes/functions_datastore.php b/includes/functions_datastore.php index 13ba2ca..ca9f379 100755 --- a/includes/functions_datastore.php +++ b/includes/functions_datastore.php @@ -25,7 +25,7 @@ function build_languages() global $bugsys; $languages = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "language"); - while ($language = $bugsys->db->fetch_array($languages)) + foreach ($languages as $language) { $tempstore["$language[languageid]"] = $language; } @@ -45,7 +45,7 @@ function build_settings() global $bugsys; $settings = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "setting"); - while ($setting = $bugsys->db->fetch_array($settings)) + foreach ($settings as $setting) { $options["$setting[varname]"] = $setting['value']; } @@ -65,7 +65,7 @@ function build_usergroups() global $bugsys; $usergroups = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "usergroup"); - while ($usergroup = $bugsys->db->fetch_array($usergroups)) + foreach ($usergroups as $usergroup) { $groups["$usergroup[usergroupid]"] = $usergroup; } @@ -85,7 +85,7 @@ function build_statuses() global $bugsys; $statuses = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "status ORDER BY displayorder ASC"); - while ($status = $bugsys->db->fetch_array($statuses)) + foreach ($statuses as $status) { $tempstore["$status[statusid]"] = $status; } @@ -105,7 +105,7 @@ function build_severities() global $bugsys; $severities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder ASC"); - while ($severity = $bugsys->db->fetch_array($severities)) + foreach ($severities as $severity) { $tempstore["$severity[severityid]"] = $severity; } @@ -125,7 +125,7 @@ function build_priorities() global $bugsys; $priorities = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder ASC"); - while ($priority = $bugsys->db->fetch_array($priorities)) + foreach ($priorities as $priority) { $tempstore["$priority[priorityid]"] = $priority; } @@ -162,7 +162,7 @@ function build_assignedto() FROM " . TABLE_PREFIX . "user AS user WHERE usergroupid IN ($ids) OR $exprs" ); - while ($user = $bugsys->db->fetch_array($users)) + foreach ($users as $user) { $devs["$user[userid]"] = $user; } @@ -182,7 +182,7 @@ function build_resolutions() global $bugsys; $resolutions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder ASC"); - while ($resolution = $bugsys->db->fetch_array($resolutions)) + foreach ($resolutions as $resolution) { $tempstore["$resolution[resolutionid]"] = $resolution; } @@ -202,7 +202,7 @@ function build_versions() global $bugsys; $versions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder ASC"); - while ($version = $bugsys->db->fetch_array($versions)) + foreach ($versions as $version) { $tempstore["$version[versionid]"] = $version; } @@ -222,7 +222,7 @@ function build_products() global $bugsys; $products = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); - while ($product = $bugsys->db->fetch_array($products)) + foreach ($products as $product) { if ($product['parentid']) { @@ -252,7 +252,7 @@ function build_permissions() global $bugsys; $permissions = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "permission ORDER BY usergroupid, productid"); - while ($permission = $bugsys->db->fetch_array($permissions)) + foreach ($permissions as $permission) { $tempstore["$permission[usergroupid]"]["$permission[productid]"] = $permission['mask']; } @@ -272,7 +272,7 @@ function build_automations() global $bugsys; $automations = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "automation ORDER BY name ASC"); - while ($automation = $bugsys->db->fetch_array($automations)) + foreach ($automations as $automation) { $actions["$automation[actionid]"] = $automation; } @@ -293,14 +293,14 @@ function build_user_help() // custom field descriptions $descriptions = $bugsys->db->query("SELECT fieldid, name, description FROM " . TABLE_PREFIX . "bugfield"); - while ($field = $bugsys->db->fetch_array($descriptions)) + foreach ($descriptions as $field) { $help["field$field[fieldid]"] = array('title' => $field['name'], 'body' => $field['description']); } // standard help texts $texts = $bugsys->db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp"); - while ($field = $bugsys->db->fetch_array($texts)) + foreach ($texts as $field) { $help["$field[keystring]"] = $field; } diff --git a/install/convert_database_charset.php b/install/convert_database_charset.php index def3532..190c730 100644 --- a/install/convert_database_charset.php +++ b/install/convert_database_charset.php @@ -91,7 +91,7 @@ else if ($bugsys->in['step'] == 1) while ($table = $db->fetch_array($tables, false)) { $columns = $db->query("SHOW FULL COLUMNS FROM $table[0]"); - while ($col = $db->fetch_array($columns)) + foreach ($columns as $col) { if (!is_null($col['Collation']) AND (strpos($col['Type'], 'char') !== false OR strpos($col['Type'], 'text') !== false)) { diff --git a/install/upgrade11.php b/install/upgrade11.php index a8575f5..167eeb2 100644 --- a/install/upgrade11.php +++ b/install/upgrade11.php @@ -104,7 +104,7 @@ if ($bugsys->in['mark'] == 3) query("SELECT * FROM " . TABLE_PREFIX . "bugfield"); - while ($field = $db->fetch_array($fields)) + foreach ($fields as $field) { // create the database field $db->query("ALTER TABLE " . TABLE_PREFIX . "bug ADD custom$field[fieldid] MEDIUMTEXT NULL"); @@ -113,7 +113,7 @@ if ($bugsys->in['mark'] == 3) // update all the data $data = $db->query("SELECT * FROM " . TABLE_PREFIX . "bugvaluefill"); - while ($custom = $db->fetch_array($data)) + foreach ($data as $custom) { echo "."; $db->query("UPDATE " . TABLE_PREFIX . "bug SET custom$field[fieldid] = '" . $db->escape_string($custom["field$field[fieldid]"]) . "' WHERE bugid = $custom[bugid]"); diff --git a/install/upgrade2.php b/install/upgrade2.php index 9b04826..e7542a5 100644 --- a/install/upgrade2.php +++ b/install/upgrade2.php @@ -142,13 +142,13 @@ if ($bugsys->in['mark'] == 4) $userlist = array(); $users = $db->query("SELECT userid, displayname FROM " . TABLE_PREFIX . "user"); - while ($user = $db->fetch_array($users)) + foreach ($users as $user) { $userlist["$user[userid]"] = $user['displayname']; } $bugs = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug"); - while ($bug = $db->fetch_array($bugs)) + foreach ($bugs as $bug) { $db->query(" UPDATE " . TABLE_PREFIX . "bug @@ -176,7 +176,7 @@ if ($bugsys->in['mark'] == 5) echo "Updating historical records"; $history = $db->query("SELECT * FROM " . TABLE_PREFIX . "history"); - while ($log = $db->fetch_array($history)) + foreach ($history as $log) { $matches = array(); if (preg_match('#custom_field([0-9]+?)#i', $log['field'], $matches)) @@ -225,7 +225,7 @@ if ($bugsys->in['mark'] == 6) echo "Setting email options"; $users = $db->query("SELECT userid FROM " . TABLE_PREFIX . "user"); - while ($user = $db->fetch_array($users)) + foreach ($users as $user) { $db->query(" INSERT INTO " . TABLE_PREFIX . "useremail diff --git a/search.php b/search.php index a56c28a..2cd5865 100644 --- a/search.php +++ b/search.php @@ -149,7 +149,7 @@ if ($_REQUEST['do'] == 'search') if (bugdar::$userinfo['userid']) { $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . bugdar::$userinfo['userid']); - while ($search = $db->fetch_array($searchesFetch)) + foreach ($searchesFetch as $search) { $value = $search['searchid']; $label = $search['name']; @@ -298,7 +298,7 @@ if ($_REQUEST['do'] == 'process') if ($bugsys->in['favorite'] != 0 AND bugdar::$userinfo['userid']) { $favorites = $db->query("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid']); - while ($favorite = $db->fetch_array($favorites)) + foreach ($favorites as $favorite) { $ids[] = $favorite['bugid']; } @@ -335,7 +335,7 @@ if ($_REQUEST['do'] == 'process') AND bugfield.cansearch = 1 GROUP BY (bugfield.fieldid)" ); - while ($field = $bugsys->db->fetch_array($fields_fetch)) + foreach ($fields_fetch as $field) { if (!empty($bugsys->in["custom$field[fieldid]"]) OR ($field['type'] == 'select_single' AND isset($bugsys->in["custom$field[fieldid]"]))) { @@ -392,7 +392,7 @@ if ($_REQUEST['do'] == 'process') $message->error(T('No search results were returned that matched your criteria. Please try again with different search requirements.')); } - while ($result = $db->fetch_array($search)) + foreach ($search as $result) { $ids[] = $result['bugid']; $results[] = $result; @@ -512,7 +512,7 @@ if ($_POST['do'] == 'doupdate') (userid = " . bugdar::$userinfo['userid'] . " AND product IN (" . fetch_on_bits('caneditown') . ")) ) "); - while ($bug = $db->fetch_array($bugs)) + foreach ($bugs as $bug) { if (!((can_perform('caneditown', $bug['product']) AND bugdar::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar::$userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product'])) { @@ -595,7 +595,7 @@ if ($_REQUEST['do'] == 'export') '; - while ($bug = $db->fetch_array($bugs)) + foreach ($bugs as $bug) { $xml .= "\n\t"; @@ -696,7 +696,7 @@ if ($_POST['do'] == 'results') $bugs = ''; $search = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($search[ids]) $search[orderby] LIMIT " . $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()); - while ($bug = $db->fetch_array($search)) + foreach ($search as $bug) { $funct->exec_swap_bg('altcolor', ''); $bug = ProcessBugDataForDisplay($bug, $funct->bgcolour); diff --git a/showhistory.php b/showhistory.php index de31c51..f1802a7 100644 --- a/showhistory.php +++ b/showhistory.php @@ -64,7 +64,7 @@ $customfields = $db->query(" GROUP BY (bugfield.fieldid)" ); -while ($field = $db->fetch_array($customfields)) +foreach ($customfields as $field) { $fieldlist["$field[fieldid]"] = sprintf(T('Custom Field %1$s (%2$s)'), $field['fieldid'], $field['name']); } @@ -79,7 +79,7 @@ $logs_fetch = $db->query(" ON (user.userid = history.userid) WHERE bugid = $bug[bugid]" ); -while ($log = $db->fetch_array($logs_fetch)) +foreach ($logs_fetch as $log) { $log['date'] = $datef->format(bugdar::$options['dateformat'], $log['dateline']); $log['user'] = construct_user_display($log); diff --git a/showreport.php b/showreport.php index befc103..c46bd47 100644 --- a/showreport.php +++ b/showreport.php @@ -126,7 +126,7 @@ if ($show['edit']) { $depends = array(); $dependencies = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($bug[dependency])"); - while ($dependency = $db->fetch_array($dependencies)) + foreach ($dependencies as $dependency) { $depends[] = "$dependency[bugid]"; } @@ -173,7 +173,7 @@ else $dupelist = array(); $duplicates = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE duplicateof = $bug[bugid]"); - while ($duplicate = $db->fetch_array($duplicates)) + foreach ($duplicates as $duplicate) { $dupelist[] = "$duplicate[summary]"; } @@ -183,7 +183,7 @@ else { $depends = array(); $dependencies = $db->query("SELECT bugid, summary FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($bug[dependency])"); - while ($dependency = $db->fetch_array($dependencies)) + foreach ($dependencies as $dependency) { $depends[] = "$dependency[bugid]"; } @@ -262,7 +262,7 @@ if ($show['getattachments'] OR $show['putattachments']) ); $attaches = false; - while ($attachment = $db->fetch_array($attachments_fetch)) + foreach ($attachments_fetch as $attachment) { $attaches = true; $show['editattach'] = ((can_perform('caneditattach', $bug['productid']) OR ($attachment['userid'] == bugdar::$userinfo['userid'] AND can_perform('canputattach', $bug['productid']))) ? true : false); @@ -304,7 +304,7 @@ $comments_fetch = $db->query(" AND !hidden" : '') . " ORDER BY comment.dateline ASC" ); -while ($comment = $db->fetch_array($comments_fetch)) +foreach ($comments_fetch as $comment) { $comment['posttime'] = $datef->format(bugdar::$options['dateformat'], $comment['dateline']); $comment['postby'] = construct_user_display($comment); diff --git a/syndicate.php b/syndicate.php index a9febca..9d45d0b 100644 --- a/syndicate.php +++ b/syndicate.php @@ -46,7 +46,7 @@ $bugs_fetch = $db->query(" ORDER BY " . (can_perform('canviewhidden', 0, fetch_guest_user()) ? "bug.lastposttime" : "bug.hiddenlastposttime") . " DESC LIMIT " . bugdar::$options['syndicateditems'] ); -while ($bug = $db->fetch_array($bugs_fetch)) +foreach ($bugs_fetch as $bug) { $syndicate .= ' diff --git a/userctrl.php b/userctrl.php index 878b5fc..2cc6cc7 100644 --- a/userctrl.php +++ b/userctrl.php @@ -220,7 +220,7 @@ if ($_REQUEST['do'] == 'modify') if (!is_array($bugsys->in['emailopts'])) { $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . bugdar::$userinfo['userid']); - while ($opt = $db->fetch_array($options)) + foreach ($options as $opt) { foreach ($bugsys->emailoptions['notifications'] AS $name => $notif) { @@ -279,7 +279,7 @@ if ($_REQUEST['do'] == 'modify') // searches $searches = ''; $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . bugdar::$userinfo['userid']); - while ($search = $db->fetch_array($searchesFetch)) + foreach ($searchesFetch as $search) { eval('$searches .= "' . $template->fetch('userctrl_search') . '";'); } -- 2.22.5