Skip to content

Commit

Permalink
Bug 1565403 - Log how a bug was filed (via standard, guided, custom b…
Browse files Browse the repository at this point in the history
…ug form or API)
  • Loading branch information
kyoshino authored and dklawren committed Aug 8, 2019
1 parent 0c0355f commit a9a21fc
Show file tree
Hide file tree
Showing 46 changed files with 112 additions and 8 deletions.
22 changes: 21 additions & 1 deletion Bugzilla/Bug.pm
Expand Up @@ -91,6 +91,7 @@ sub DB_COLUMNS {
delta_ts
estimated_time
everconfirmed
filed_via
lastdiffed
op_sys
priority
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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'}
Expand Down Expand Up @@ -873,6 +884,7 @@ sub possible_duplicates {
# C<status_whiteboard> - A string.
# C<bug_status> - The initial status of the bug, a string.
# C<bug_file_loc> - The URL field.
# C<filed_via> - How this bug is being filed.
#
# C<assigned_to> - The full login name of the user who the bug is
# initially assigned to.
Expand Down Expand Up @@ -1959,6 +1971,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)');
}
Expand Down Expand Up @@ -2644,7 +2663,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
Expand Down Expand Up @@ -3686,6 +3705,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} }
Expand Down
1 change: 1 addition & 0 deletions Bugzilla/Field.pm
Expand Up @@ -422,6 +422,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',
Expand Down
14 changes: 14 additions & 0 deletions Bugzilla/Hook.pm
Expand Up @@ -400,6 +400,20 @@ User is not a sufficiently empowered user, so B<deny>.
=back
=head2 bug_file_methods
This happens in L<Bugzilla::Bug/BUG_FILE_METHODS>, and allows you to add one or
more valid file methods stored with bugs.
Params:
=over
=item C<method> - 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
Expand Down
25 changes: 23 additions & 2 deletions Bugzilla/WebService/Bug.pm
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<filed_via>
How the bug was filed, e.g. C<standard_form>.
This is an B<extra> field returned only by specifying C<filed_via> or
C<_extra> in C<include_fields>.
=item C<flags>
An array of hashes containing the information about flags currently set
Expand Down Expand Up @@ -3218,8 +3231,9 @@ and all custom fields.
in Bugzilla B<4.4>.
=item The C<attachments>, C<comment_count>, C<comments>, C<counts>,
C<description>, C<duplicates>, C<history>, C<regressed_by>, C<regressions>,
C<triage_owner> and C<type> fields were added in Bugzilla B<6.0>.
C<description>, C<duplicates>, C<filed_via>, C<history>, C<regressed_by>,
C<regressions>, C<triage_owner> and C<type> fields were added in Bugzilla
B<6.0>.
=back
Expand Down Expand Up @@ -3497,6 +3511,10 @@ backwards compatibility with older Bugzillas.
C<string> The description (initial comment) of the bug.
=item C<filed_via>
C<string> Searches for bugs that were created with this method.
=item C<id>
C<int> The numeric id of the bug.
Expand Down Expand Up @@ -3726,6 +3744,9 @@ the version the bug was found in.
=item C<description> (string) B<Defaulted> - The description (initial comment)
of the bug. Some Bugzilla installations require this to not be blank.
=item C<filed_via> (string) B<Defaulted> - How the bug is being filed.
It will be C<api> by default when filing through the API.
=item C<op_sys> (string) B<Defaulted> - The operating system the bug was
discovered on.
Expand Down
2 changes: 1 addition & 1 deletion bugzilla.dtd
Expand Up @@ -5,7 +5,7 @@
maintainer CDATA #REQUIRED
exporter CDATA #IMPLIED
>
<!ELEMENT bug (bug_id, (alias?, creation_ts, short_desc, delta_ts, reporter_accessible,
<!ELEMENT bug (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, bug_status, resolution?, dup_id?, duplicates*, see_also*,
bug_file_loc?, status_whiteboard?, keywords*, bug_type, priority, bug_severity,
Expand Down
4 changes: 4 additions & 0 deletions docs/en/rst/api/core/v1/bug.rst
Expand Up @@ -262,6 +262,7 @@ counts object An object containing the numbers of the items in th
``depends_on``, ``regressed_by``, ``regressions``
and ``duplicates``.
description string The description (initial comment) of the bug.
filed_via string How the bug was filed, e.g. ``standard_form``.
history array Each array item is a History object. See
:ref:`rest_history` for details of the object.
tags array Each array item is a tag name. Note that tags are
Expand Down Expand Up @@ -504,6 +505,7 @@ creator string The login name of the user who created the bug. You
``reporter``, for backwards compatibility with
older Bugzillas.
description string The description (initial comment) of the bug.
filed_via string Searches for bugs that were created with this method.
id int The numeric ID of the bug.
last_change_time datetime Searches for bugs that were modified at this time
or later. May not be an array.
Expand Down Expand Up @@ -645,6 +647,8 @@ name type description
description string (defaulted) The description (initial comment) of the
bug. Some Bugzilla installations require this to not
be blank.
filed_via string (defaulted) How the bug is being filed. It will be
``api`` by default when filing through the API.
op_sys string (defaulted) The operating system the bug was
discovered on.
platform string (defaulted) What type of hardware the bug was
Expand Down
Expand Up @@ -80,6 +80,7 @@ function validateAndSubmit() {

<form id="automative_form" method="post" action="[% basepath FILTER none %]post_bug.cgi"
enctype="multipart/form-data" onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="automative">
<input type="hidden" name="product" value="Testing">
<input type="hidden" name="component" value="General">
Expand Down
Expand Up @@ -131,6 +131,7 @@ window.addEventListener("DOMContentLoaded", function() {
[% cgi = Bugzilla.cgi %]

<form id="blocklist_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data" class="noscript" onSubmit="return validateAndSubmit()">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="product" value="Toolkit">
<input type="hidden" name="component" value="Blocklist Policy Requests">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -112,6 +112,7 @@ function validateAndSubmit() {

<form id="client_bounty_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="product" value="Firefox">
<input type="hidden" name="component" value="Security">
<input type="hidden" name="rep_platform" value="unspecified">
Expand Down
Expand Up @@ -81,6 +81,7 @@ function toggleAreaOther() {

<form id="newsletter_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="comm-newsletter">
<input type="hidden" name="product" value="Marketing">
<input type="hidden" name="component" value="Community">
Expand Down
Expand Up @@ -143,6 +143,7 @@ YAHOO.util.Event.onDOMReady(function() {

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="costume">
<input type="hidden" name="product" value="Marketing">
<input type="hidden" name="component" value="General">
Expand Down
Expand Up @@ -115,6 +115,7 @@ function toggleTypeOther(element) {

<form id="creative_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="creative">
<input type="hidden" name="product" value="Marketing">
<input type="hidden" name="component" value="Design">
Expand Down
Expand Up @@ -85,6 +85,7 @@ $(document).ready(function() {
the invite details once you submit the [% terms.bug %]):</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="crmForm">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="short_desc" name="short_desc" value="CRM/Email Marketing Request">
<input type="hidden" name="product" value="Marketing">
<input type="hidden" name="component" value="Email">
Expand Down
Expand Up @@ -75,6 +75,7 @@
<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="data_comp_form"
class="enter_bug_form" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="data-compliance">
<input type="hidden" name="product" value="Data Compliance">
<input type="hidden" name="component" value="General">
Expand Down
Expand Up @@ -77,6 +77,7 @@

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="bug_form" class="enter_bug_form"
enctype="multipart/form-data" onsubmit="return onSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="finance">
<input type="hidden" name="product" value="Finance">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -84,6 +84,7 @@ function validateAndSubmit() {

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="fsa_form" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="fsa-budget">
<input type="hidden" name="product" value="FSA">
<input type="hidden" name="component" value="Budget Requests">
Expand Down
Expand Up @@ -107,6 +107,7 @@ $(document).ready(function() {
</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="internForm">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="short_desc" name="short_desc" value="">
<input type="hidden" name="product" value="Recruiting">
<input type="hidden" name="component" value="Intern">
Expand Down
Expand Up @@ -65,6 +65,7 @@ function validateAndSubmit() {

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="ipp">
<input type="hidden" name="product" value="Internet Public Policy">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -93,6 +93,7 @@

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="itRequestForm" enctype="multipart/form-data"
onsubmit="return on_submit()">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="product" name="product" value="Infrastructure & Operations">
<input type="hidden" name="rep_platform" value="All">
<input type="hidden" name="op_sys" value="Other">
Expand Down
Expand Up @@ -76,6 +76,7 @@ label.required:before {
<p>[ <span class="required_star">*</span> Required Field ]</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="legalRequestForm" enctype="multipart/form-data">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="product" value="Legal">
<input type="hidden" name="rep_platform" value="All">
<input type="hidden" name="op_sys" value="Other">
Expand Down
Expand Up @@ -178,6 +178,7 @@ strong.required:before {

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return mdn.validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="mdn">
<input type="hidden" name="product" value="developer.mozilla.org">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -77,6 +77,7 @@ function validateAndSubmit() {

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="mobile-compat">
<input type="hidden" name="product" value="Tech Evangelism">
<input type="hidden" name="component" value="Mobile">
Expand Down
Expand Up @@ -62,6 +62,7 @@

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="mozListRequestForm"
enctype="multipart/form-data" onSubmit="return trySubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="format" name="format" value="mozlist">
<input type="hidden" id="product" name="product" value="mozilla.org">
<input type="hidden" id="rep_platform" name="rep_platform" value="All">
Expand Down
Expand Up @@ -284,6 +284,7 @@ function validate_form() {

<form id="pr_form" name="pr_form" method="post" action="[% basepath FILTER none %]post_bug.cgi"
enctype="multipart/form-data" onSubmit="return validate_form()">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="mozpr">
<input type="hidden" name="product" value="Mozilla PR">
<input type="hidden" name="component" value="Projects">
Expand Down
Expand Up @@ -72,6 +72,7 @@ $(function() {
<p>[ <span class="required_star">*</span> <span class="required_explanation">Required Field</span> ]</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="nameForm">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="short_desc" name="short_desc" value="New Name Clearance Request">
<input type="hidden" name="product" value="Legal">
<input type="hidden" name="component" value="Name Clearance (Trademark Search)">
Expand Down
Expand Up @@ -63,6 +63,7 @@ $(function() {
of the ticket.</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="ndaForm">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" id="short_desc" name="short_desc" value="New NDA Request">
<input type="hidden" name="product" value="Legal">
<input type="hidden" name="component" value="NDA">
Expand Down
Expand Up @@ -34,6 +34,7 @@
</ul>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="recoveryKeyForm" enctype="multipart/form-data">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="product" value="mozilla.org">
<input type="hidden" name="component" value="Server Operations: Desktop Issues">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -72,6 +72,7 @@ function jobDescToggle(what) {
</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="recruitingForm" enctype="multipart/form-data">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="product" value="Recruiting">
<input type="hidden" name="component" value="General">
<input type="hidden" name="rep_platform" value="All">
Expand Down
Expand Up @@ -90,6 +90,7 @@ function fieldValue(elem_id) {

<form id="whitelist_form" method="post" action="[% basepath FILTER none %]post_bug.cgi" enctype="multipart/form-data"
onSubmit="return validateAndSubmit();">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" value="screen-share-whitelist">
<input type="hidden" name="product" value="Firefox">
<input type="hidden" name="component" value="Screen Sharing Whitelist">
Expand Down
Expand Up @@ -43,6 +43,7 @@
</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="shieldStudies" class="enter_bug_form" enctype="multipart/form-data">
<input type="hidden" name="filed_via" value="custom_form">
<input type="hidden" name="format" id="format" value="shield-studies">
<input type="hidden" name="product" id="product" value="Shield">
<input type="hidden" name="component" id="component" value="Shield Study">
Expand Down

0 comments on commit a9a21fc

Please sign in to comment.