mimetype => 'content_type',
};
-our %api_field_types = (
- %{{map { $_ => 'double' } Bugzilla::Bug::NUMERIC_COLUMNS()}},
- %{{map { $_ => 'dateTime' } Bugzilla::Bug::DATE_COLUMNS()}},
-);
+our $api_field_types = sub {
+ Bugzilla::request_cache->{api_field_types} ||= {
+ %{{map { $_ => 'double' } Bugzilla::Bug::NUMERIC_COLUMNS()}},
+ %{{map { $_ => 'dateTime' } Bugzilla::Bug::DATE_COLUMNS()}},
+ };
+};
-our %api_field_names = reverse %{Bugzilla::Bug::FIELD_MAP()};
+our $api_field_names = sub {
+ Bugzilla::request_cache->{api_field_types} ||= do {
+ my $tmp = {reverse %{Bugzilla::Bug::FIELD_MAP()}};
-# This doesn't normally belong in FIELD_MAP, but we do want to translate
-# "bug_group" back into "groups".
-$api_field_names{'bug_group'} = 'groups';
+ # This doesn't normally belong in FIELD_MAP, but we do want to translate
+ # "bug_group" back into "groups".
+ $tmp->{'bug_group'} = 'groups';
+ $tmp;
+ };
+};
######################################################
# Add aliases here for old method name compatibility #
}
my %changes = %{$all_changes{$bug->id}};
+ my $names = $api_field_names->();
foreach my $field (keys %changes) {
my $change = $changes{$field};
- my $api_field = $api_field_names{$field} || $field;
+ my $api_field = $names->{$field} || $field;
# We normalize undef to an empty string, so that the API
# stays consistent for things like Deadline that can become
foreach my $change (@{$changeset->{changes}}) {
my $field_name = delete $change->{fieldname};
- my $api_field_type = $api_field_types{$field_name} || 'string';
- my $api_field_name = $api_field_names{$field_name} || $field_name;
+ my $api_field_type = $api_field_types->()->{$field_name} || 'string';
+ my $api_field_name = $api_field_names->()->{$field_name} || $field_name;
my $attach_id = delete $change->{attachid};
my $comment = delete $change->{comment};