summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-21 00:58:44 +0200
committerlpsolit%gmail.com <>2005-07-21 00:58:44 +0200
commitb0d0cb1523a0d6742ededb3cd1fc26e483cfc0fa (patch)
tree1e23663cfeece9ed7317be4a80f0815fd6360d3c /Bugzilla/Bug.pm
parentf0a9bdd03c1a9e8fb55870143995165595f386af (diff)
downloadbugzilla-b0d0cb1523a0d6742ededb3cd1fc26e483cfc0fa.tar.gz
bugzilla-b0d0cb1523a0d6742ededb3cd1fc26e483cfc0fa.tar.xz
Bug 301440: Move LogActivityEntry out of CGI.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=justdave
Diffstat (limited to 'Bugzilla/Bug.pm')
-rwxr-xr-xBugzilla/Bug.pm48
1 files changed, 48 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index a82df3b69..c7e763748 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -52,10 +52,22 @@ use base qw(Exporter);
AppendComment ValidateComment
bug_alias_to_id ValidateBugAlias ValidateBugID
RemoveVotes CheckIfVotedConfirmed
+ LogActivityEntry
);
+#####################################################################
+# Constants
+#####################################################################
+
+# Used in LogActivityEntry(). Gives the max length of lines in the
+# activity table.
+use constant MAX_LINE_LENGTH => 254;
+
+# Used in ValidateComment(). Gives the max length allowed for a comment.
use constant MAX_COMMENT_LENGTH => 65535;
+#####################################################################
+
sub fields {
# Keep this ordering in sync with bugzilla.dtd
my @fields = qw(bug_id alias creation_ts short_desc delta_ts
@@ -918,6 +930,42 @@ sub GetBugActivity {
return(\@operations, $incomplete_data);
}
+# Update the bugs_activity table to reflect changes made in bugs.
+sub LogActivityEntry {
+ my ($i, $col, $removed, $added, $whoid, $timestamp) = @_;
+ my $dbh = Bugzilla->dbh;
+ # in the case of CCs, deps, and keywords, there's a possibility that someone
+ # might try to add or remove a lot of them at once, which might take more
+ # space than the activity table allows. We'll solve this by splitting it
+ # into multiple entries if it's too long.
+ while ($removed || $added) {
+ my ($removestr, $addstr) = ($removed, $added);
+ if (length($removestr) > MAX_LINE_LENGTH) {
+ my $commaposition = find_wrap_point($removed, MAX_LINE_LENGTH);
+ $removestr = substr($removed, 0, $commaposition);
+ $removed = substr($removed, $commaposition);
+ $removed =~ s/^[,\s]+//; # remove any comma or space
+ } else {
+ $removed = ""; # no more entries
+ }
+ if (length($addstr) > MAX_LINE_LENGTH) {
+ my $commaposition = find_wrap_point($added, MAX_LINE_LENGTH);
+ $addstr = substr($added, 0, $commaposition);
+ $added = substr($added, $commaposition);
+ $added =~ s/^[,\s]+//; # remove any comma or space
+ } else {
+ $added = ""; # no more entries
+ }
+ trick_taint($addstr);
+ trick_taint($removestr);
+ my $fieldid = &::GetFieldID($col);
+ $dbh->do("INSERT INTO bugs_activity
+ (bug_id, who, bug_when, fieldid, removed, added)
+ VALUES (?, ?, ?, ?, ?, ?)",
+ undef, ($i, $whoid, $timestamp, $fieldid, $removestr, $addstr));
+ }
+}
+
# CountOpenDependencies counts the number of open dependent bugs for a
# list of bugs and returns a list of bug_id's and their dependency count
# It takes one parameter: