summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fearn <jfearn@redhat.com>2020-12-08 10:29:50 +1000
committerJeff Fearn <jfearn@redhat.com>2020-12-08 10:29:50 +1000
commit61e1d32a99a04de92ed98648963db2954f796f1d (patch)
tree6837c394305a82d48322af7e3f8d38dce3189677
parentRelease Version 5.0.4-rh50 (diff)
downloadbugzilla-61e1d32a99a04de92ed98648963db2954f796f1d.tar.gz
bugzilla-61e1d32a99a04de92ed98648963db2954f796f1d.tar.bz2
bugzilla-61e1d32a99a04de92ed98648963db2954f796f1d.zip
Bug 1904247 - extra private groups for comments submitted outside of bug update transaction
Add a field so log can be more sepcific. Make new field hostory only visible to insiders. Move DB update from set_all to update scope. Change-Id: I029f4f14fcb38dd0fc463f9e8bbed1ce71d1e88e
-rw-r--r--extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl3
-rw-r--r--extensions/RedHat/Extension.pm43
-rw-r--r--extensions/RedHat/lib/Schema.pm10
3 files changed, 39 insertions, 17 deletions
diff --git a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
index bf2f55e66..32bc9411f 100644
--- a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
+++ b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl
@@ -75,6 +75,9 @@
[%# reference the comment that was made private/public in the field label %]
html += '<a href="#c[% change.comment.count FILTER js %]">'
+ 'Comment [% change.comment.count FILTER js %]</a> is private: ';
+ [% ELSIF change.fieldname == 'longdescs.extra_groups' %]
+ html += '<a href="#c[% change.comment.count FILTER js %]">'
+ + 'Comment [% change.comment.count FILTER js %]</a> extra private groups: ';
[% ELSE %]
[%# normal label %]
html += '[% field_descs.${change.fieldname} FILTER js %]: ';
diff --git a/extensions/RedHat/Extension.pm b/extensions/RedHat/Extension.pm
index 0a65ddbd1..22eae68a5 100644
--- a/extensions/RedHat/Extension.pm
+++ b/extensions/RedHat/Extension.pm
@@ -655,6 +655,10 @@ sub bug_filter_change {
}
## REDHAT EXTENSION END 915533
+ if ($field eq 'longdescs.extra_groups' && !$user->is_insider) {
+ $$visible = 0;
+ }
+
return;
}
@@ -1079,22 +1083,6 @@ sub bug_before_set_all {
}
## REDHAT EXTENSION END 798022
- ## REDHAT EXTENSION START 1824881
- if ($user->is_insider) {
- foreach my $key (keys %$input) {
- if ($key =~ /defined_extra_private_groups_(\d+)$/) {
- my $comment_id = $1;
- my $com_groups = [];
- if (exists $input->{"extra_private_groups_$comment_id"}) {
- $com_groups = $input->{"extra_private_groups_$comment_id"};
- $com_groups = [$com_groups] if (ref($com_groups) ne 'ARRAY');
- }
- $bug->edit_private_groups($comment_id, $com_groups);
- }
- }
- }
- ## REDHAT EXTENSION END 1824881
-
return;
}
@@ -1243,6 +1231,8 @@ sub bug_start_of_update {
my $changes = $args->{changes};
my $delta_ts = $args->{timestamp};
my $dbh = Bugzilla->dbh;
+ my $input = Bugzilla->input_params;
+ my $user = Bugzilla->user;
## RED HAT EXTENSION START 1174396
if ($bug->product_obj->name eq 'Fedora') {
@@ -1458,10 +1448,29 @@ sub bug_start_of_update {
## REDHAT EXTENSION START 420461
## REDHAT EXTENSION START 1824881
+ if ($user->is_insider) {
+ foreach my $key (keys %$input) {
+ if ($key =~ /defined_extra_private_groups_(\d+)$/) {
+ my $comment_id = $1;
+ my $com_groups = [];
+ if (exists $input->{"extra_private_groups_$comment_id"}) {
+ $com_groups = $input->{"extra_private_groups_$comment_id"};
+ $com_groups = [$com_groups] if (ref($com_groups) ne 'ARRAY');
+ }
+ $bug->edit_private_groups($comment_id, $com_groups);
+ }
+ }
+ }
my $edited_comment_private_groups = 0;
foreach my $comment (@{$bug->{edited_comment_private_groups} || []}) {
- $changes->{'longdesc'} = [$comment->{count}, 'comment private groups updated'];
+ LogActivityEntry(
+ $bug->id, "longdescs.extra_groups",
+ join(', ', @{$comment->{removed}}),
+ join(', ', @{$comment->{added}}),
+ $user->id, $delta_ts, $comment->{comment_id}
+ );
}
+
delete $bug->{edited_comment_private_groups}; # delete in case $bug->update is called again.
## REDHAT EXTENSION START 1824881
diff --git a/extensions/RedHat/lib/Schema.pm b/extensions/RedHat/lib/Schema.pm
index ea23ffda9..9f0f2c655 100644
--- a/extensions/RedHat/lib/Schema.pm
+++ b/extensions/RedHat/lib/Schema.pm
@@ -766,6 +766,16 @@ EOS
}
## REDHAT EXTENSION END 1821023
+ if (!defined Bugzilla::Field->new({name => "longdescs.extra_groups"})) {
+ Bugzilla::Field->create({
+ name => "longdescs.extra_groups",
+ description => "Extra Private Groups",
+ is_numeric => 0,
+ buglist => 0,
+ mailhead => 0,
+ });
+ }
+
return;
}