aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bugzilla.pm11
-rwxr-xr-xBugzilla/Bug.pm21
-rw-r--r--Bugzilla/Field.pm7
-rwxr-xr-xbuglist.cgi2
-rwxr-xr-xcolchange.cgi2
-rwxr-xr-xconfig.cgi4
-rwxr-xr-xenter_bug.cgi3
-rwxr-xr-ximportxml.pl4
-rwxr-xr-xpost_bug.cgi10
-rwxr-xr-xprocess_bug.cgi2
-rw-r--r--template/en/default/bug/create/create.html.tmpl5
-rw-r--r--template/en/default/bug/edit.html.tmpl15
-rw-r--r--template/en/default/bug/show-multiple.html.tmpl2
-rw-r--r--template/en/default/list/edit-multiple.html.tmpl2
14 files changed, 42 insertions, 48 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index c77c039ce..e35c75934 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -430,10 +430,13 @@ sub get_fields {
return @$fields;
}
-sub custom_field_names {
- # Get a list of custom fields and convert it into a list of their names.
- return map($_->{name},
- @{Bugzilla::Field->match({ custom=>1, obsolete=>0 })});
+sub active_custom_fields {
+ my $class = shift;
+ if (!exists $class->request_cache->{active_custom_fields}) {
+ $class->request_cache->{active_custom_fields} =
+ Bugzilla::Field->match({ custom => 1, obsolete => 0 });
+ }
+ return @{$class->request_cache->{active_custom_fields}};
}
sub hook_args {
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 5cbe8a619..a5d25885e 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -68,8 +68,8 @@ use constant LIST_ORDER => ID_FIELD;
# This is a sub because it needs to call other subroutines.
sub DB_COLUMNS {
my $dbh = Bugzilla->dbh;
- my @custom = Bugzilla->get_fields({ custom => 1, obsolete => 0});
- @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT} @custom;
+ my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my @custom_names = map {$_->name} @custom;
return qw(
alias
@@ -130,8 +130,7 @@ sub VALIDATORS {
};
# Set up validators for custom fields.
- my @custom_fields = Bugzilla->get_fields({custom => 1, obsolete => 0});
- foreach my $field (@custom_fields) {
+ foreach my $field (Bugzilla->active_custom_fields) {
my $validator;
if ($field->type == FIELD_TYPE_SINGLE_SELECT) {
$validator = \&_check_select_field;
@@ -167,8 +166,8 @@ use constant UPDATE_VALIDATORS => {
};
sub UPDATE_COLUMNS {
- my @custom = Bugzilla->get_fields({ custom => 1, obsolete => 0});
- @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT} @custom;
+ my @custom = grep {$_->type != FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my @custom_names = map {$_->name} @custom;
my @columns = qw(
alias
@@ -566,8 +565,8 @@ sub update {
}
# Insert the values into the multiselect value tables
- my @multi_selects = Bugzilla->get_fields(
- { custom => 1, type => FIELD_TYPE_MULTI_SELECT, obsolete => 0 });
+ my @multi_selects = grep {$_->type == FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
foreach my $field (@multi_selects) {
my $name = $field->name;
my ($removed, $added) = diff_arrays($old_bug->$name, $self->$name);
@@ -625,8 +624,8 @@ sub update {
sub _extract_multi_selects {
my ($invocant, $params) = @_;
- my @multi_selects = Bugzilla->get_fields(
- { custom => 1, type => FIELD_TYPE_MULTI_SELECT, obsolete => 0 });
+ my @multi_selects = grep {$_->type == FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields;
my %ms_values;
foreach my $field (@multi_selects) {
my $name = $field->name;
@@ -1581,7 +1580,7 @@ sub fields {
# Conditional Fields
Bugzilla->params->{'useqacontact'} ? "qa_contact" : (),
# Custom Fields
- Bugzilla->custom_field_names
+ map { $_->name } Bugzilla->active_custom_fields
);
}
diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm
index 5272f0ed6..0d7479034 100644
--- a/Bugzilla/Field.pm
+++ b/Bugzilla/Field.pm
@@ -30,17 +30,14 @@ Bugzilla::Field - a particular piece of information about bugs
print Dumper(Bugzilla->get_fields());
# Display information about non-obsolete custom fields.
- print Dumper(Bugzilla->get_fields({ obsolete => 1, custom => 1 }));
-
- # Display a list of the names of non-obsolete custom fields.
- print Bugzilla->custom_field_names;
+ print Dumper(Bugzilla->active_custom_fields);
use Bugzilla::Field;
# Display information about non-obsolete custom fields.
# Bugzilla->get_fields() is a wrapper around Bugzilla::Field->match(),
# so both methods take the same arguments.
- print Dumper(Bugzilla::Field->match({ obsolete => 1, custom => 1 }));
+ print Dumper(Bugzilla::Field->match({ obsolete => 0, custom => 1 }));
# Create or update a custom field or field definition.
my $field = Bugzilla::Field->create(
diff --git a/buglist.cgi b/buglist.cgi
index b87cdf970..670844bb9 100755
--- a/buglist.cgi
+++ b/buglist.cgi
@@ -672,7 +672,7 @@ DefineColumn("percentage_complete",
DefineColumn("relevance" , "relevance" , "Relevance" );
DefineColumn("deadline" , $dbh->sql_date_format('bugs.deadline', '%Y-%m-%d') . " AS deadline", "Deadline");
-foreach my $field (Bugzilla->get_fields({ custom => 1, obsolete => 0})) {
+foreach my $field (Bugzilla->active_custom_fields) {
DefineColumn($field->name, 'bugs.' . $field->name, $field->description);
}
diff --git a/colchange.cgi b/colchange.cgi
index c580547ce..b2d33de7e 100755
--- a/colchange.cgi
+++ b/colchange.cgi
@@ -81,7 +81,7 @@ if (Bugzilla->user->in_group(Bugzilla->params->{"timetrackinggroup"})) {
push(@masterlist, ("short_desc", "short_short_desc"));
my @custom_fields = grep { $_->type != FIELD_TYPE_MULTI_SELECT }
- Bugzilla->get_fields({ custom => 1, obsolete => 0 });
+ Bugzilla->active_custom_fields;
push(@masterlist, map { $_->name } @custom_fields);
$vars->{'masterlist'} = \@masterlist;
diff --git a/config.cgi b/config.cgi
index ad8dbf0fe..026b070d6 100755
--- a/config.cgi
+++ b/config.cgi
@@ -56,8 +56,8 @@ $vars->{'keyword'} = [map($_->name, Bugzilla::Keyword->get_all)];
$vars->{'resolution'} = get_legal_field_values('resolution');
$vars->{'status'} = get_legal_field_values('bug_status');
$vars->{'custom_fields'} =
- [Bugzilla->get_fields({custom => 1, obsolete => 0, type => FIELD_TYPE_SINGLE_SELECT}),
- Bugzilla->get_fields({custom => 1, obsolete => 0, type => FIELD_TYPE_MULTI_SELECT})];
+ [ grep {$_->type == FIELD_TYPE_SINGLE_SELECT || $_->type == FIELD_TYPE_MULTI_SELECT}
+ Bugzilla->active_custom_fields ];
# Include a list of product objects.
if ($cgi->param('product')) {
diff --git a/enter_bug.cgi b/enter_bug.cgi
index cce5a431e..ee362e302 100755
--- a/enter_bug.cgi
+++ b/enter_bug.cgi
@@ -383,8 +383,7 @@ $vars->{'cloned_bug_id'} = $cloned_bug_id;
$vars->{'token'} = issue_session_token('createbug:');
-my @enter_bug_fields = Bugzilla->get_fields({ custom => 1, obsolete => 0,
- enter_bug => 1 });
+my @enter_bug_fields = grep { $_->enter_bug } Bugzilla->active_custom_fields;
foreach my $field (@enter_bug_fields) {
$vars->{$field->name} = formvalue($field->name);
}
diff --git a/importxml.pl b/importxml.pl
index 80506971c..1ed9253b8 100755
--- a/importxml.pl
+++ b/importxml.pl
@@ -1028,9 +1028,9 @@ sub process_bug {
push( @values, $status );
# Custom fields
- foreach my $custom_field (Bugzilla->custom_field_names) {
+ foreach my $field (Bugzilla->active_custom_fields) {
+ my $custom_field = $field->name;
next unless defined($bug_fields{$custom_field});
- my $field = new Bugzilla::Field({name => $custom_field});
if ($field->type == FIELD_TYPE_FREETEXT) {
push(@query, $custom_field);
push(@values, clean_text($bug_fields{$custom_field}));
diff --git a/post_bug.cgi b/post_bug.cgi
index fbfdf27f7..957e7b75f 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -124,8 +124,8 @@ $template->process($format->{'template'}, $vars, \$comment)
|| ThrowTemplateError($template->error());
# Include custom fields editable on bug creation.
-my @custom_bug_fields = grep {$_->type != FIELD_TYPE_MULTI_SELECT}
- Bugzilla->get_fields({ custom => 1, obsolete => 0, enter_bug => 1 });
+my @custom_bug_fields = grep {$_->type != FIELD_TYPE_MULTI_SELECT && $_->enter_bug}
+ Bugzilla->active_custom_fields;
# Undefined custom fields are ignored to ensure they will get their default
# value (e.g. "---" for custom single select fields).
@@ -167,9 +167,9 @@ $bug_params{'cc'} = [$cgi->param('cc')];
$bug_params{'groups'} = \@selected_groups;
$bug_params{'comment'} = $comment;
-my @multi_selects = Bugzilla->get_fields(
- { type => FIELD_TYPE_MULTI_SELECT, custom => 1, obsolete => 0,
- enter_bug => 1 });
+my @multi_selects = grep {$_->type == FIELD_TYPE_MULTI_SELECT && $_->enter_bug}
+ Bugzilla->active_custom_fields;
+
foreach my $field (@multi_selects) {
$bug_params{$field->name} = [$cgi->param($field->name)];
}
diff --git a/process_bug.cgi b/process_bug.cgi
index 4ea6c1f7f..93b2ec1ff 100755
--- a/process_bug.cgi
+++ b/process_bug.cgi
@@ -307,7 +307,7 @@ my @set_fields = qw(op_sys rep_platform priority bug_severity
deadline remaining_time estimated_time);
push(@set_fields, 'assigned_to') if !$cgi->param('set_default_assignee');
push(@set_fields, 'qa_contact') if !$cgi->param('set_default_qa_contact');
-my @custom_fields = Bugzilla->get_fields({custom => 1, obsolete => 0});
+my @custom_fields = Bugzilla->active_custom_fields;
my %methods = (
bug_severity => 'set_severity',
diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl
index 8bc4ab465..c8fd0fc10 100644
--- a/template/en/default/bug/create/create.html.tmpl
+++ b/template/en/default/bug/create/create.html.tmpl
@@ -421,10 +421,9 @@ function handleWantsAttachment(wants_attachment) {
<tbody>
[% USE Bugzilla %]
- [% custom_fields = Bugzilla.get_fields({ obsolete => 0, custom => 1,
- enter_bug => 1 }) %]
- [% FOREACH field = custom_fields %]
+ [% FOREACH field = Bugzilla.active_custom_fields %]
+ [% NEXT UNLESS field.enter_bug %]
[% SET value = ${field.name} IF ${field.name}.defined %]
<tr>
[% PROCESS bug/field.html.tmpl editable=1 value_span=3 %]
diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl
index 63913beee..1cdf5e798 100644
--- a/template/en/default/bug/edit.html.tmpl
+++ b/template/en/default/bug/edit.html.tmpl
@@ -907,15 +907,12 @@
[%# *** Custom Fields *** %]
[% USE Bugzilla %]
- [% fields = Bugzilla.get_fields({ obsolete => 0, custom => 1 }) %]
- [% IF fields %]
- [% FOREACH field = fields %]
- <tr>
- [% PROCESS bug/field.html.tmpl value=bug.${field.name}
- editable = bug.check_can_change_field(field.name, 0, 1)
- value_span = 2 %]
- </tr>
- [% END %]
+ [% FOREACH field = Bugzilla.active_custom_fields %]
+ <tr>
+ [% PROCESS bug/field.html.tmpl value=bug.${field.name}
+ editable = bug.check_can_change_field(field.name, 0, 1)
+ value_span = 2 %]
+ </tr>
[% END %]
[% END %]
diff --git a/template/en/default/bug/show-multiple.html.tmpl b/template/en/default/bug/show-multiple.html.tmpl
index 2104c90a4..2562903a6 100644
--- a/template/en/default/bug/show-multiple.html.tmpl
+++ b/template/en/default/bug/show-multiple.html.tmpl
@@ -178,7 +178,7 @@
[% USE Bugzilla %]
[% field_counter = 0 %]
- [% FOREACH field = Bugzilla.get_fields({ obsolete => 0, custom => 1 }) %]
+ [% FOREACH field = Bugzilla.active_custom_fields %]
[% field_counter = field_counter + 1 %]
[%# Odd-numbered fields get an opening <tr> %]
[% '<tr>' IF field_counter % 2 %]
diff --git a/template/en/default/list/edit-multiple.html.tmpl b/template/en/default/list/edit-multiple.html.tmpl
index 9aa110359..5607371eb 100644
--- a/template/en/default/list/edit-multiple.html.tmpl
+++ b/template/en/default/list/edit-multiple.html.tmpl
@@ -240,7 +240,7 @@
[% END %]
[% USE Bugzilla %]
- [% FOREACH field = Bugzilla.get_fields({ obsolete => 0, custom => 1 }) %]
+ [% FOREACH field = Bugzilla.active_custom_fields %]
<tr>
[% PROCESS bug/field.html.tmpl value = dontchange
editable = 1