diff options
author | mkanat%bugzilla.org <> | 2006-09-16 07:18:46 +0000 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2006-09-16 07:18:46 +0000 |
commit | cc3a19cb43e162ede1237986ea535a42c03cb423 (patch) | |
tree | 5760e6bbfc34ca0e77481cc46dd1ced158a93159 /Bugzilla | |
parent | 4d734cd3df63127e644af23ac8fb822b6516e3fe (diff) | |
download | bugs-cc3a19cb43e162ede1237986ea535a42c03cb423.tar bugs-cc3a19cb43e162ede1237986ea535a42c03cb423.tar.gz bugs-cc3a19cb43e162ede1237986ea535a42c03cb423.tar.bz2 bugs-cc3a19cb43e162ede1237986ea535a42c03cb423.tar.xz bugs-cc3a19cb43e162ede1237986ea535a42c03cb423.zip |
Bug 351888: Move comment creation out of post_bug.cgi and into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=mkanat, a=myk
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 36 | ||||
-rw-r--r-- | Bugzilla/DB/Schema.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 3 |
3 files changed, 35 insertions, 6 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index eeffb4c71..d309d0bc2 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -116,6 +116,8 @@ sub VALIDATORS { bug_file_loc => \&_check_bug_file_loc, bug_severity => \&_check_bug_severity, cc => \&_check_cc, + comment => \&_check_comment, + commentprivacy => \&_check_commentprivacy, deadline => \&_check_deadline, estimated_time => \&_check_estimated_time, keywords => \&_check_keywords, @@ -253,6 +255,9 @@ sub create { delete $params->{dependson}; my $blocked = $params->{blocked}; delete $params->{blocked}; + my ($comment, $privacy) = ($params->{comment}, $params->{commentprivacy}); + delete $params->{comment}; + delete $params->{commentprivacy}; # Set up the keyword cache for bug creation. my $keywords = $params->{keywords}; @@ -264,6 +269,10 @@ sub create { my $timestamp = $params->{creation_ts}; delete $params->{creation_ts}; + $dbh->bz_lock_tables('bugs WRITE', 'bug_group_map WRITE', + 'longdescs WRITE', 'cc WRITE', 'keywords WRITE', 'dependencies WRITE', + 'bugs_activity WRITE', 'fielddefs READ'); + my $bug = $class->insert_create_data($params); # Add the group restrictions @@ -296,15 +305,23 @@ sub create { $sth_deps->execute($bug->bug_id, $depends_on_id); # Log the reverse action on the other bug. LogActivityEntry($depends_on_id, 'blocked', '', $bug->bug_id, - $bug->reporter->id, $timestamp); + $bug->{reporter_id}, $timestamp); } foreach my $blocked_id (@$blocked) { $sth_deps->execute($blocked_id, $bug->bug_id); # Log the reverse action on the other bug. LogActivityEntry($blocked_id, 'dependson', '', $bug->bug_id, - $bug->reporter->id, $timestamp); + $bug->{reporter_id}, $timestamp); } + # And insert the comment. We always insert a comment on bug creation, + # but sometimes it's blank. + $dbh->do('INSERT INTO longdescs (bug_id, who, bug_when, thetext, isprivate) + VALUES (?, ?, ?, ?, ?)', undef, + $bug->bug_id, $bug->{reporter_id}, $timestamp, $comment, $privacy); + + $dbh->bz_unlock_tables(); + return $bug; } @@ -504,9 +521,7 @@ sub _check_cc { sub _check_comment { my ($invocant, $comment) = @_; - if (!defined $comment) { - ThrowCodeError('undefined_field', { field => 'comment' }); - } + $comment = '' unless defined $comment; # Remove any trailing whitespace. Leading whitespace could be # a valid part of the comment. @@ -519,9 +534,20 @@ sub _check_comment { ThrowUserError("description_required"); } + # On creation only, there must be a single-space comment, or + # email will be supressed. + $comment = ' ' if $comment eq '' && !ref($invocant); + return $comment; } +sub _check_commentprivacy { + my ($invocant, $comment_privacy) = @_; + my $insider_group = Bugzilla->params->{"insidergroup"}; + return ($insider_group && Bugzilla->user->in_group($insider_group) + && $comment_privacy) ? 1 : 0; +} + sub _check_component { my ($invocant, $product, $name) = @_; $name = trim($name); diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 90385798f..938ef042a 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -270,7 +270,7 @@ use constant ABSTRACT_SCHEMA => { bug_when => {TYPE => 'DATETIME', NOTNULL => 1}, work_time => {TYPE => 'decimal(5,2)', NOTNULL => 1, DEFAULT => '0'}, - thetext => {TYPE => 'MEDIUMTEXT'}, + thetext => {TYPE => 'MEDIUMTEXT', NOTNULL => 1}, isprivate => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}, already_wrapped => {TYPE => 'BOOLEAN', NOTNULL => 1, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 2e364c540..d1d154c53 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -493,6 +493,9 @@ sub update_table_definitions { $dbh->bz_add_column('setting', 'subclass', {TYPE => 'varchar(32)'}); + $dbh->bz_alter_column('longdescs', 'thetext', + { TYPE => 'MEDIUMTEXT', NOTNULL => 1 }, ''); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ |