From c5a676ad9f8e3d82e3ae27087114c321204ee0d5 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Mon, 16 May 2016 15:23:19 +0000 Subject: Bug 1261114 - Release notes cannot be displayed due to missing REQUIRED_MODULES and OPTIONAL_MODULES r=dylan --- Bugzilla/Template.pm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 49294244a..40079339a 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -1153,18 +1153,32 @@ sub create { # These don't work as normal constants. DB_MODULE => \&Bugzilla::Constants::DB_MODULE, - REQUIRED_MODULES => - \&Bugzilla::Install::Requirements::REQUIRED_MODULES, + REQUIRED_MODULES => sub { + my %required_modules; + my $cache = Bugzilla->request_cache; + my $meta = $cache->{cpan_meta} ||= Bugzilla::Install::Requirements::load_cpan_meta(); + my $reqs = $meta->effective_prereqs->merged_requirements(['configure', 'runtime'], ['requires']); + foreach my $module (sort $reqs->required_modules) { + next if $module eq 'perl'; + $required_modules{$module} = { version => $reqs->requirements_for_module($module) }; + } + return \%required_modules; + }, OPTIONAL_MODULES => sub { - my @optional = @{OPTIONAL_MODULES()}; - foreach my $item (@optional) { - my @features; - foreach my $feat_id (@{ $item->{feature} }) { - push(@features, install_string("feature_$feat_id")); + my %optional_modules; + my $cache = Bugzilla->request_cache; + my $meta = $cache->{cpan_meta} ||= Bugzilla::Install::Requirements::load_cpan_meta(); + foreach my $feature ($meta->features) { + my $reqs = $feature->prereqs->merged_requirements(['configure', 'runtime'], ['requires']); + foreach my $module ($reqs->required_modules) { + my $version = $reqs->requirements_for_module($module); + $optional_modules{$module} ||= {}; + $optional_modules{$module}{version} = $version; + $optional_modules{$module}{features} ||= []; + push(@{$optional_modules{$module}{features}}, $feature->description); } - $item->{feature} = \@features; } - return \@optional; + return \%optional_modules; }, 'default_authorizer' => sub { return Bugzilla::Auth->new() }, -- cgit v1.2.3-24-g4f1b