From: Kohei Yoshino
Date: Fri, 2 Aug 2019 16:35:46 +0000 (-0400)
Subject: Bug 1565403 - Log how a bug was filed (via standard, guided, custom bug form or API)
X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0837a10c11642a4bb71665fb4456442a9be620d4;p=thirdparty%2Fbugzilla.git
Bug 1565403 - Log how a bug was filed (via standard, guided, custom bug form or API)
---
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index bc5416fc4..5a224451f 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -91,6 +91,7 @@ sub DB_COLUMNS {
delta_ts
estimated_time
everconfirmed
+ filed_via
lastdiffed
op_sys
priority
@@ -130,6 +131,7 @@ sub VALIDATORS {
dup_id => \&_check_dup_id,
estimated_time => \&_check_time_field,
everconfirmed => \&Bugzilla::Object::check_boolean,
+ filed_via => \&_check_filed_via,
groups => \&_check_groups,
keywords => \&_check_keywords,
op_sys => \&_check_select_field,
@@ -311,6 +313,15 @@ use constant REQUIRED_FIELD_MAP =>
use constant EXTRA_REQUIRED_FIELDS =>
qw(creation_ts target_milestone cc qa_contact groups);
+sub BUG_FILE_METHODS {
+ my @methods = qw(standard_form custom_form api);
+
+ # Allow extensions to add other methods, e.g. `guided_form`
+ Bugzilla::Hook::process('bug_file_methods', {methods => \@methods});
+
+ return @methods;
+}
+
with 'Bugzilla::Elastic::Role::Object';
sub ES_TYPE {'bug'}
@@ -873,6 +884,7 @@ sub possible_duplicates {
# C - A string.
# C - The initial status of the bug, a string.
# C - The URL field.
+# C - How this bug is being filed.
#
# C - The full login name of the user who the bug is
# initially assigned to.
@@ -1948,6 +1960,13 @@ sub _check_component {
return $object;
}
+sub _check_filed_via {
+ my ($invocant, $method) = @_;
+
+ return $method if defined $method && grep(/^$method$/, BUG_FILE_METHODS());
+ return 'unknown';
+}
+
sub _check_creation_ts {
return Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
}
@@ -2633,7 +2652,7 @@ sub fields {
# Standard Fields
# Keep this ordering in sync with bugzilla.dtd.
- qw(bug_id alias creation_ts short_desc delta_ts
+ qw(bug_id alias filed_via creation_ts short_desc delta_ts
reporter_accessible cclist_accessible
classification_id classification
product component version rep_platform op_sys
@@ -3675,6 +3694,7 @@ sub deadline { return $_[0]->{deadline} }
sub delta_ts { return $_[0]->{delta_ts} }
sub error { return $_[0]->{error} }
sub everconfirmed { return $_[0]->{everconfirmed} }
+sub filed_via { return $_[0]->{filed_via} }
sub lastdiffed { return $_[0]->{lastdiffed} }
sub op_sys { return $_[0]->{op_sys} }
sub priority { return $_[0]->{priority} }
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index dce61c08b..2ea176c50 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -247,6 +247,7 @@ use constant ABSTRACT_SCHEMA => {
bug_severity => {TYPE => 'varchar(64)', NOTNULL => 1},
bug_status => {TYPE => 'varchar(64)', NOTNULL => 1},
bug_type => {TYPE => 'varchar(20)', NOTNULL => 1},
+ filed_via => {TYPE => 'varchar(40)', NOTNULL => 1, DEFAULT => "'unknown'"},
creation_ts => {TYPE => 'DATETIME'},
delta_ts => {TYPE => 'DATETIME', NOTNULL => 1},
short_desc => {TYPE => 'varchar(255)', NOTNULL => 1},
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 503befdb9..e19f85435 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -423,6 +423,7 @@ use constant DEFAULT_FIELDS => (
},
{name => 'target_milestone', desc => 'Target Milestone', buglist => 1},
+ {name => 'filed_via', desc => 'Filed via', buglist => 1,},
{
name => 'creation_ts',
desc => 'Opened',
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 22b15c876..ad6c8ebab 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -400,6 +400,20 @@ User is not a sufficiently empowered user, so B.
=back
+=head2 bug_file_methods
+
+This happens in L, and allows you to add one or
+more valid file methods stored with bugs.
+
+Params:
+
+=over
+
+=item C - A arrayref containing an array of method names. Push your
+method name(s) onto the array.
+
+=back
+
=head2 bug_fields
Allows the addition of database fields from the bugs table to the standard
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 6cee28e10..6ff2d4d51 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -798,6 +798,10 @@ sub update_table_definitions {
_add_oauth2_jwt_support();
+ # Bug 1565403 - kohei.yoshino@gmail.com
+ $dbh->bz_add_column('bugs', 'filed_via',
+ {TYPE => 'varchar(40)', NOTNULL => 1, DEFAULT => "'unknown'"});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 5b1dca146..1ac75a585 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -878,6 +878,9 @@ sub create {
$params = Bugzilla::Bug::map_fields($params);
+ # Define the bug file method if missing
+ $params->{filed_via} //= 'api';
+
my $flags = delete $params->{flags};
# We start a nested transaction in case flag setting fails
@@ -1526,6 +1529,9 @@ sub _bug_to_hash {
if (filter_wants $params, 'duplicates') {
$item{'duplicates'} = [map { $self->type('int', $_->id) } @{$bug->duplicates}];
}
+ if (filter_wants $params, 'filed_via', ['extra']) {
+ $item{'filed_via'} = $self->type('string', $bug->filed_via);
+ }
if (filter_wants $params, 'groups') {
my @groups = map { $self->type('string', $_->name) } @{$bug->groups_in};
$item{'groups'} = \@groups;
@@ -2868,6 +2874,13 @@ take.
If you are not in the time-tracking group, this field will not be included
in the return value.
+=item C
+
+How the bug was filed, e.g. C.
+
+This is an B field returned only by specifying C or
+C<_extra> in C.
+
=item C
An array of hashes containing the information about flags currently set
@@ -3218,8 +3231,9 @@ and all custom fields.
in Bugzilla B<4.4>.
=item The C, C, C, C,
-C, C, C, C, C,
-C and C fields were added in Bugzilla B<6.0>.
+C, C, C, C, C,
+C, C and C fields were added in Bugzilla
+B<6.0>.
=back
@@ -3497,6 +3511,10 @@ backwards compatibility with older Bugzillas.
C The description (initial comment) of the bug.
+=item C
+
+C Searches for bugs that were created with this method.
+
=item C
C The numeric id of the bug.
@@ -3726,6 +3744,9 @@ the version the bug was found in.
=item C (string) B - The description (initial comment)
of the bug. Some Bugzilla installations require this to not be blank.
+=item C (string) B - How the bug is being filed.
+It will be C by default when filing through the API.
+
=item C (string) B - The operating system the bug was
discovered on.
diff --git a/bugzilla.dtd b/bugzilla.dtd
index 88ebab14d..a9eb46935 100644
--- a/bugzilla.dtd
+++ b/bugzilla.dtd
@@ -5,7 +5,7 @@
maintainer CDATA #REQUIRED
exporter CDATA #IMPLIED
>
-
+
diff --git a/extensions/BMO/template/en/default/bug/create/create-blocklist.html.tmpl b/extensions/BMO/template/en/default/bug/create/create-blocklist.html.tmpl
index f3c95fa15..63d95e0d9 100644
--- a/extensions/BMO/template/en/default/bug/create/create-blocklist.html.tmpl
+++ b/extensions/BMO/template/en/default/bug/create/create-blocklist.html.tmpl
@@ -131,6 +131,7 @@ window.addEventListener("DOMContentLoaded", function() {
[% cgi = Bugzilla.cgi %]