- Removed potential implode() warnings in showreport.php under PHP5
- When logging out, you will be redirected to the page you were previously viewing
- Rewrote the logging mechanism
+- Usernames are now cached in the database for bug reports to remove the need to do complex joins at runtime
1.0.2
==================
## SVN $Id$
+
+ALTER TABLE bug ADD username varchar(255) NOT NULL;
+
+ALTER TABLE bug ADD lastpostbyname varchar(255) NOT NULL;
+
+ALTER TABLE bug ADD hiddenlastpostbyname varchar(255) NOT NULL;
CORE SYSTEM CHANGES
----------------------------------------
- Switch to ISSO APIs
-- Cache user information into bug reports so we don't have to do mondo-joins
----------------------------------------
BUG REPORTING/EDITING
--- /dev/null
+<?php
+
+// SVN $Id$
+
+chdir('./../');
+require_once('./global.php');
+
+$userlist = array();
+$users = $db->query("SELECT userid, displayname FROM " . TABLE_PREFIX . "user");
+while ($user = $db->fetch_array($users))
+{
+ $userlist["$user[userid]"] = $user['displayname'];
+}
+
+$bugs = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug");
+while ($bug = $db->fetch_array($bugs))
+{
+ $db->query("
+ UPDATE " . TABLE_PREFIX . "bug
+ SET username = '" . $db->escape_string($userlist["$bug[userid]"]) . "',
+ lastpostbyname = '" . $db->escape_string($userlist["$bug[lastpostby]"]) . "',
+ hiddenlastpostbyname = '" . $db->escape_string($userlist["$bug[hiddenlastpostby]"]) . "'
+ WHERE bugid = $bug[bugid]
+ ");
+}
+
+?>
\ No newline at end of file
$log->add_data(true, $commentapi->objdata, array('comment', 'hidden'), false, 'comment');
$log->add_data(false, $commentapi->values, array('comment', 'hidden'), false, 'comment');
- $lastgood = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "comment WHERE bugid = $bug[bugid] AND !hidden ORDER BY dateline DESC");
+ $lastgood = $db->query_first("
+ SELECT comment.* AS comment, user.displayname AS username
+ FROM " . TABLE_PREFIX . "comment
+ LEFT JOIN " . TABLE_PREFIX . "user AS user
+ ON (user.userid = comment.userid)
+ WHERE bugid = $bug[bugid]
+ AND !hidden ORDER BY dateline DESC
+ ");
$db->query("
UPDATE " . TABLE_PREFIX . "bug
SET hiddenlastposttime = $lastgood[dateline],
- hiddenlastpostby = $lastgood[userid]
+ hiddenlastpostby = $lastgood[userid],
+ hiddenlastpostbyname = '" . $db->escape_string($lastgood['username']) . "'
WHERE bugid = $bug[bugid]"
);
$comment->set('comment', $commenttext);
$comment->insert();
- $bugapi->set('lastposttime', $comment->values['dateline']);
- $bugapi->set('lastpostby', $bugsys->userinfo['userid']);
- $bugapi->set('hiddenlastposttime', $comment->values['dateline']);
- $bugapi->set('hiddenlastpostby', $bugsys->userinfo['userid']);
+ $bugapi->set('lastposttime', $comment->values['dateline']);
+ $bugapi->set('lastpostby', $bugsys->userinfo['userid']);
+ $bugapi->set('lastpostbyname', $bugsys->userinfo['displayname']);
+ $bugapi->set('hiddenlastposttime', $comment->values['dateline']);
+ $bugapi->set('hiddenlastpostby', $bugsys->userinfo['userid']);
+ $bugapi->set('hiddenlastpostbyname', $bugsys->userinfo['displayname']);
if (!((can_perform('caneditown', $bug['productid']) AND $bugsys->userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['productid']) AND $bugsys->userinfo['userid'] != $bug['userid'])))
{
var $fields = array(
'bugid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
'userid' => array(TYPE_UINT, REQ_NO),
+ 'username' => array(TYPE_STR, REQ_NO),
'dateline' => array(TYPE_UINT, REQ_SET),
'productid' => array(TYPE_UINT, REQ_YES, ':self'),
'componentid' => array(TYPE_UINT, REQ_NO, ':self'),
'initialreport' => array(TYPE_UINT, REQ_NO),
'lastposttime' => array(TYPE_UINT, REQ_NO),
'lastpostby' => array(TYPE_UINT, REQ_NO),
+ 'lastpostbyname' => array(TYPE_STR, REQ_NO),
'hiddenlastposttime' => array(TYPE_UINT, REQ_NO),
- 'hiddenlastpostby' => array(TYPE_UINT, REQ_NO)
+ 'hiddenlastpostby' => array(TYPE_UINT, REQ_NO),
+ 'hiddenlastpostbyname' => array(TYPE_STR, REQ_NO)
);
/**
$pagination->split_pages();
$bugs_fetch = $db->query("
- SELECT bug.*, user1.displayname AS firstreport, user2.displayname AS lastpost, user3.displayname AS hiddenlastpost
- FROM " . TABLE_PREFIX . "bug AS bug
- LEFT JOIN " . TABLE_PREFIX . "user AS user1
- ON (bug.userid = user1.userid)
- LEFT JOIN " . TABLE_PREFIX . "user AS user2
- ON (bug.lastpostby = user2.userid)
- LEFT JOIN " . TABLE_PREFIX . "user AS user3
- ON (bug.hiddenlastpostby = user3.userid)
- WHERE bug.productid IN (" . fetch_on_bits('canviewbugs') . ")
+ SELECT * FROM " . TABLE_PREFIX . "bug
+ WHERE productid IN (" . fetch_on_bits('canviewbugs') . ")
AND (!hidden OR (hidden AND productid IN (" . fetch_on_bits('canviewhidden') . ")))
- ORDER BY bug." . ((can_perform('canviewhidden')) ? "lastposttime" : "hiddenlastposttime") . " DESC
+ ORDER BY " . (can_perform('canviewhidden') ? "lastposttime" : "hiddenlastposttime") . " DESC
LIMIT " . $pagination->fetch_limit($pagination->page - 1) . ", " . $pagination->perpage
);
$bug['hiddendisplay'] = ((!can_perform('canviewhidden', $bug['productid']) AND $bug['hiddenlastposttime']) ? true : false);
- $bug['lastposttime'] = (($bug['hiddendisplay']) ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
- $bug['lastpost'] = (($bug['hiddendisplay']) ? $bug['hiddenlastpost'] : $bug['lastpost']);
+ $bug['lastposttime'] = ($bug['hiddendisplay'] ? $bug['hiddenlastposttime'] : $bug['lastposttime']);
+ $bug['lastpost'] = ($bug['hiddendisplay'] ? $bug['hiddenlastpostbyname'] : $bug['lastpostbyname']);
$bug['lastposttime'] = $datef->format($bugsys->options['dateformat'], $bug['lastposttime']);
$comment = new CommentAPI($bugsys);
$bug->set('userid', $bugsys->userinfo['userid']);
+ $bug->set('username', $bugsys->userinfo['displayname']);
$bug->set('summary', $bugsys->in['summary']);
$bug->set('severity', $bugsys->in['severity']);
$comment->insert();
$bug = new BugAPI($bugsys); // need to destroy because update will think the insert fields need to be changed, too
- $bug->set('bugid', $comment->values['bugid']);
+ $bug->set('bugid', $comment->values['bugid']);
$bug->set_condition();
- $bug->set('dateline', $comment->values['dateline']);
- $bug->set('initialreport', $comment->insertid);
- $bug->set('lastposttime', $comment->values['dateline']);
- $bug->set('lastpostby', $bugsys->userinfo['userid']);
- $bug->set('hiddenlastposttime', $comment->values['dateline']);
- $bug->set('hiddenlastpostby', $bugsys->userinfo['userid']);
+ $bug->set('dateline', $comment->values['dateline']);
+ $bug->set('initialreport', $comment->insertid);
+ $bug->set('lastposttime', $comment->values['dateline']);
+ $bug->set('lastpostby', $bugsys->userinfo['userid']);
+ $bug->set('lastpostbyname', $bugsys->userinfo['displayname']);
+ $bug->set('hiddenlastposttime', $comment->values['dateline']);
+ $bug->set('hiddenlastpostby', $bugsys->userinfo['userid']);
+ $bug->set('hiddenlastpostbyname', $bugsys->userinfo['displayname']);
$bug->update();
$message->redirect($lang->string('The bug has been added to the database.'), ($bugsys->in['submit_reload'] == '' ? "showreport.php?bugid=" . $bug->values['bugid'] : 'newreport.php'));
<td>$bug[bugid]</td>
<td>
<div><a href="showreport.php?bugid=$bug[bugid]$bug[urladd]">$bug[summary]</a></div>
- <if condition="$bug['firstreport']"><div>$bug[firstreport]</div></if>
+ <if condition="$bug['username']"><div>$bug[username]</div></if>
</td>
<td>
<div>$bug[product]</div>