summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm69
-rw-r--r--Bugzilla/BugMail.pm32
-rw-r--r--Bugzilla/Constants.pm13
-rw-r--r--Bugzilla/DB/Schema.pm3
-rw-r--r--Bugzilla/Install/DB.pm5
5 files changed, 78 insertions, 44 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index e9c8bf2e9..5e8392d9f 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1315,12 +1315,16 @@ sub bug_alias_to_id {
#####################################################################
sub AppendComment {
- my ($bugid, $whoid, $comment, $isprivate, $timestamp, $work_time) = @_;
+ my ($bugid, $whoid, $comment, $isprivate, $timestamp, $work_time,
+ $type, $extra_data) = @_;
$work_time ||= 0;
+ $type ||= CMT_NORMAL;
my $dbh = Bugzilla->dbh;
ValidateTime($work_time, "work_time") if $work_time;
trick_taint($work_time);
+ detaint_natural($type)
+ || ThrowCodeError('bad_arg', {argument => 'type', function => 'AppendComment'});
# Use the date/time we were given if possible (allowing calling code
# to synchronize the comment's timestamp with those of other records).
@@ -1329,7 +1333,7 @@ sub AppendComment {
$comment =~ s/\r\n/\n/g; # Handle Windows-style line endings.
$comment =~ s/\r/\n/g; # Handle Mac-style line endings.
- if ($comment =~ /^\s*$/) { # Nothin' but whitespace
+ if ($comment =~ /^\s*$/ && !$type) { # Nothin' but whitespace
return;
}
@@ -1338,9 +1342,11 @@ sub AppendComment {
trick_taint($comment);
my $privacyval = $isprivate ? 1 : 0 ;
$dbh->do(q{INSERT INTO longdescs
- (bug_id, who, bug_when, thetext, isprivate, work_time)
- VALUES (?,?,?,?,?,?)}, undef,
- ($bugid, $whoid, $timestamp, $comment, $privacyval, $work_time));
+ (bug_id, who, bug_when, thetext, isprivate, work_time,
+ type, extra_data)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)}, undef,
+ ($bugid, $whoid, $timestamp, $comment, $privacyval, $work_time,
+ $type, $extra_data));
$dbh->do("UPDATE bugs SET delta_ts = ? WHERE bug_id = ?",
undef, $timestamp, $bugid);
}
@@ -1402,29 +1408,54 @@ sub ValidateTime {
}
sub GetComments {
- my ($id, $comment_sort_order) = (@_);
+ my ($id, $comment_sort_order, $start, $end) = @_;
+ my $dbh = Bugzilla->dbh;
+
$comment_sort_order = $comment_sort_order ||
Bugzilla->user->settings->{'comment_sort_order'}->{'value'};
my $sort_order = ($comment_sort_order eq "oldest_to_newest") ? 'asc' : 'desc';
- my $dbh = Bugzilla->dbh;
+
my @comments;
- my $sth = $dbh->prepare(
- "SELECT profiles.realname AS name, profiles.login_name AS email,
- " . $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i:%s') . "
- AS time, longdescs.thetext AS body, longdescs.work_time,
- isprivate, already_wrapped
- FROM longdescs, profiles
- WHERE profiles.userid = longdescs.who
- AND longdescs.bug_id = ?
- ORDER BY longdescs.bug_when $sort_order");
- $sth->execute($id);
+ my @args = ($id);
+
+ my $query = 'SELECT profiles.realname AS name, profiles.login_name AS email, ' .
+ $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i:%s') .
+ ' AS time, longdescs.thetext AS body, longdescs.work_time,
+ isprivate, already_wrapped, type, extra_data
+ FROM longdescs
+ INNER JOIN profiles
+ ON profiles.userid = longdescs.who
+ WHERE longdescs.bug_id = ?';
+ if ($start) {
+ $query .= ' AND longdescs.bug_when > ?
+ AND longdescs.bug_when <= ?';
+ push(@args, ($start, $end));
+ }
+ $query .= " ORDER BY longdescs.bug_when $sort_order";
+ my $sth = $dbh->prepare($query);
+ $sth->execute(@args);
while (my $comment_ref = $sth->fetchrow_hashref()) {
my %comment = %$comment_ref;
$comment{'email'} .= Bugzilla->params->{'emailsuffix'};
$comment{'name'} = $comment{'name'} || $comment{'email'};
+ if ($comment{'type'} == CMT_DUPE_OF) {
+ $comment{'body'} .= "\n\n" . get_text('bug_duplicate_of',
+ { dupe_of => $comment{'extra_data'} });
+ }
+ elsif ($comment{'type'} == CMT_HAS_DUPE) {
+ $comment{'body'} = get_text('bug_has_duplicate',
+ { dupe => $comment{'extra_data'} });
+ }
+ elsif ($comment{'type'} == CMT_POPULAR_VOTES) {
+ $comment{'body'} = get_text('bug_confirmed_by_votes');
+ }
+ elsif ($comment{'type'} == CMT_MOVED_TO) {
+ $comment{'body'} .= "\n\n" . get_text('bug_moved_to',
+ { login => $comment{'extra_data'} });
+ }
push (@comments, \%comment);
}
@@ -1760,9 +1791,7 @@ sub CheckIfVotedConfirmed {
"VALUES (?, ?, ?, ?, ?, ?)",
undef, ($id, $who, $timestamp, $fieldid, '0', '1'));
- AppendComment($id, $who,
- "*** This bug has been confirmed by popular vote. ***",
- 0, $timestamp);
+ AppendComment($id, $who, "", 0, $timestamp, 0, CMT_POPULAR_VOTES);
$ret = 1;
}
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 9a83b1cd3..6ba6b3c77 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -652,17 +652,6 @@ sub get_comments_by_bug {
my $count = 0;
my $anyprivate = 0;
- my $query = 'SELECT profiles.login_name, profiles.realname, ' .
- $dbh->sql_date_format('longdescs.bug_when', '%Y.%m.%d %H:%i') . ',
- longdescs.thetext, longdescs.isprivate,
- longdescs.already_wrapped
- FROM longdescs
- INNER JOIN profiles
- ON profiles.userid = longdescs.who
- WHERE longdescs.bug_id = ? ';
-
- my @args = ($id);
-
# $start will be undef for new bugs, and defined for pre-existing bugs.
if ($start) {
# If $start is not NULL, obtain the count-index
@@ -670,26 +659,21 @@ sub get_comments_by_bug {
$count = $dbh->selectrow_array('SELECT COUNT(*) FROM longdescs
WHERE bug_id = ? AND bug_when <= ?',
undef, ($id, $start));
-
- $query .= ' AND longdescs.bug_when > ?
- AND longdescs.bug_when <= ? ';
- push @args, ($start, $end);
}
- $query .= ' ORDER BY longdescs.bug_when';
- my $comments = $dbh->selectall_arrayref($query, undef, @args);
+ my $comments = Bugzilla::Bug::GetComments($id, "oldest_to_newest", $start, $end);
- foreach (@$comments) {
- my ($who, $whoname, $when, $text, $isprivate, $already_wrapped) = @$_;
+ foreach my $comment (@$comments) {
if ($count) {
- $result .= "\n\n--- Comment #$count from $whoname <$who" .
- Bugzilla->params->{'emailsuffix'}. "> "
- . format_time($when) . " ---\n";
+ $result .= "\n\n--- Comment #$count from " . $comment->{'name'} . " <" .
+ $comment->{'email'} . Bugzilla->params->{'emailsuffix'} . "> " .
+ format_time($comment->{'time'}) . " ---\n";
}
- if ($isprivate > 0 && Bugzilla->params->{'insidergroup'}) {
+ if ($comment->{'isprivate'} > 0 && Bugzilla->params->{'insidergroup'}) {
$anyprivate = 1;
}
- $result .= ($already_wrapped ? $text : wrap_comment($text));
+ $result .= ($comment->{'already_wrapped'} ? $comment->{'body'}
+ : wrap_comment($comment->{'body'}));
$count++;
}
return ($result, $anyprivate);
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 5186fcbce..89032c0b0 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -81,6 +81,12 @@ use File::Basename;
COMMENT_COLS
+ CMT_NORMAL
+ CMT_DUPE_OF
+ CMT_HAS_DUPE
+ CMT_POPULAR_VOTES
+ CMT_MOVED_TO
+
UNLOCK_ABORT
THROW_ERROR
@@ -231,6 +237,13 @@ use constant LIST_OF_BUGS => 1;
# The column length for displayed (and wrapped) bug comments.
use constant COMMENT_COLS => 80;
+# The type of bug comments.
+use constant CMT_NORMAL => 0;
+use constant CMT_DUPE_OF => 1;
+use constant CMT_HAS_DUPE => 2;
+use constant CMT_POPULAR_VOTES => 3;
+use constant CMT_MOVED_TO => 4;
+
# used by Bugzilla::DB to indicate that tables are being unlocked
# because of error
use constant UNLOCK_ABORT => 1;
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index c45419a37..7aa77108e 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -276,6 +276,9 @@ use constant ABSTRACT_SCHEMA => {
DEFAULT => 'FALSE'},
already_wrapped => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
+ type => {TYPE => 'INT2', NOTNULL => 1,
+ DEFAULT => '0'},
+ extra_data => {TYPE => 'varchar(255)'}
],
INDEXES => [
longdescs_bug_id_idx => ['bug_id'],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 9592976b6..5c3c1485a 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -509,6 +509,11 @@ sub update_table_definitions {
$dbh->bz_add_column('group_control_map', 'canconfirm',
{TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'});
+ # 2006-11-07 LpSolit@gmail.com - Bug 353656
+ $dbh->bz_add_column('longdescs', 'type',
+ {TYPE => 'INT2', NOTNULL => 1, DEFAULT => '0'});
+ $dbh->bz_add_column('longdescs', 'extra_data', {TYPE => 'varchar(255)'});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################