From baf16d0f78665c6181297bbff4a9bac23382252b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 23 Dec 2004 20:46:31 +0000 Subject: [PATCH] r18: Fixed showreport.php to not query comments and the bug report in one (the joins get confused and it becomes a mess). It's now two queries and we no longer have to create the arrays of data and then foreach() them. --- showreport.php | 62 +++++++++++++------------------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/showreport.php b/showreport.php index 7af4863..4780273 100644 --- a/showreport.php +++ b/showreport.php @@ -37,57 +37,19 @@ if ($_REQUEST['do'] == 'modify') exit; } - $bugfetch = $DB_sql->query(" - SELECT bug.*, user1.displayname, user1.email, user1.showemail, - comment.userid AS posterid, user2.displayname AS postedby, - user2.email AS posteremail, user2.showemail AS postershowemail, - comment.comment, comment.dateline AS postedon + $bug = $DB_sql->query_first(" + SELECT bug.*, user.displayname, user.email, user.showemail FROM " . TABLE_PREFIX . "bug AS bug - LEFT JOIN " . TABLE_PREFIX . "comment AS comment - ON (bug.bugid = comment.bugid) - LEFT JOIN " . TABLE_PREFIX . "user AS user1 - ON (bug.userid = user1.userid) - LEFT JOIN " . TABLE_PREFIX . "user AS user2 - ON (comment.userid = user1.userid) - WHERE bug.bugid = $vars[bugid] - ORDER BY comment.dateline ASC" + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (bug.userid = user.userid) + WHERE bug.bugid = $vars[bugid]" ); - while ($buginfo = $DB_sql->fetch_array($bugfetch)) - { - if (!is_array($bug)) - { - $bug = array( - 'bugid' => $buginfo['bugid'], - 'userid' => $buginfo['userid'], - 'displayname' => $buginfo['displayname'], - 'email' => $buginfo['email'], - 'showemail' => $buginfo['showemail'], - 'productid' => $buginfo['productid'], - 'componentid' => $buginfo['componentid'], - 'versionid' => $buginfo['versionid'], - 'summary' => $buginfo['summary'], - 'priority' => $buginfo['priority'], - 'severity' => $buginfo['severity'], - 'status' => $buginfo['status'], - 'resolution' => $buginfo['resolution'], - 'assignedto' => $buginfo['assignedto'] - ); - } - $comments[] = array( - 'userid' => $buginfo['posterid'], - 'displayname' => $buginfo['displayname'], - 'email' => $buginfo['posteremail'], - 'showemail' => $buginfo['postershowemail'], - 'dateline' => $buginfo['postedon'], - 'comment' => $buginfo['comment'] - ); - } if (!is_array($bug)) { echo 'alert: bad bug'; exit; - } + } echo "
Bug ID: $bug[bugid]
"; echo "
Reported by: $bug[displayname]" . iff($bug['showemail'], " <$bug[email]>") . " (userid: $bug[userid])
"; @@ -101,12 +63,20 @@ if ($_REQUEST['do'] == 'modify') echo '
'; - foreach ($comments AS $comment) + $comments = $DB_sql->query(" + SELECT comment.*, user.email, user.showemail, user.displayname + FROM " . TABLE_PREFIX . "comment AS comment + LEFT JOIN " . TABLE_PREFIX . "user AS user + ON (comment.userid = user.userid) + WHERE comment.bugid = $vars[bugid] + ORDER BY comment.dateline ASC" + ); + while ($comment = $DB_sql->fetch_array($comments)) { echo '"; echo "
' . datelike('standard', $comment['dateline']) . '' . $comment['displayname'] . iff($comment['showemail'], " <$comment[email]>") . " (userid: $comment[userid])
" . nl2br($comment['comment']) . "
"; } - + if ($bugsys->userinfo['permissions'] & CANPOSTCOMMENTS) { echo "
[New Comment]
"; -- 2.43.5