summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2011-01-11 00:05:53 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2011-01-11 00:05:53 +0100
commita9ec34d1c1c7973ccc6718c63d1823310d842df0 (patch)
tree83c9cafa920f852e49a6d1d6d618f6b59db75cdc
parent6da18342f1be71130dbcb39a0c4fac453ac9f7c5 (diff)
downloadbugzilla-a9ec34d1c1c7973ccc6718c63d1823310d842df0.tar.gz
bugzilla-a9ec34d1c1c7973ccc6718c63d1823310d842df0.tar.xz
Bug 624349: Let the config_modify_panels hook add new parameters to existing panels
r/a=mkanat
-rw-r--r--Bugzilla/Config.pm21
1 files changed, 10 insertions, 11 deletions
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index a7184866f..a211e3021 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -48,8 +48,6 @@ use File::Temp;
);
Exporter::export_ok_tags('admin');
-use vars qw(@param_list);
-
# INITIALISATION CODE
# Perl throws a warning if we use bz_locations() directly after do.
our %params;
@@ -62,15 +60,17 @@ sub _load_params {
eval("require $module") || die $@;
my @new_param_list = $module->get_param_list();
$hook_panels{lc($panel)} = { params => \@new_param_list };
- foreach my $item (@new_param_list) {
- $params{$item->{'name'}} = $item;
- }
- push(@param_list, @new_param_list);
}
# This hook is also called in editparams.cgi. This call here is required
# to make SetParam work.
Bugzilla::Hook::process('config_modify_panels',
{ panels => \%hook_panels });
+
+ foreach my $panel (keys %hook_panels) {
+ foreach my $item (@{$hook_panels{$panel}->{params}}) {
+ $params{$item->{'name'}} = $item;
+ }
+ }
}
# END INIT CODE
@@ -203,8 +203,8 @@ sub update_params {
# --- DEFAULTS FOR NEW PARAMS ---
_load_params unless %params;
- foreach my $item (@param_list) {
- my $name = $item->{'name'};
+ foreach my $name (keys %params) {
+ my $item = $params{$name};
unless (exists $param->{$name}) {
print "New parameter: $name\n" unless $new_install;
if (exists $answer->{$name}) {
@@ -223,9 +223,8 @@ sub update_params {
my %oldparams;
# Remove any old params
foreach my $item (keys %$param) {
- if (!grep($_ eq $item, map ($_->{'name'}, @param_list))) {
- $oldparams{$item} = $param->{$item};
- delete $param->{$item};
+ if (!exists $params{$item}) {
+ $oldparams{$item} = delete $param->{$item};
}
}