From 15daaf123635c1e734dfe6e3aed60f52df0364ce Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 27 Mar 2017 09:56:14 -0400 Subject: Bug 1350466 - Uplift bug 1342832 to bmo for performance and other reasons --- Bugzilla.pm | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'Bugzilla.pm') diff --git a/Bugzilla.pm b/Bugzilla.pm index bd410364e..1f8d9d800 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -33,12 +33,12 @@ use Bugzilla::Flag; use Bugzilla::Hook; use Bugzilla::Install::Localconfig qw(read_localconfig); use Bugzilla::Install::Util qw(init_console include_languages); -use Bugzilla::Install::Requirements qw(load_cpan_meta check_cpan_feature); use Bugzilla::Memcached; use Bugzilla::Template; use Bugzilla::Token; use Bugzilla::User; use Bugzilla::Util; +use Bugzilla::CPAN; use Bugzilla::Metrics::Collector; use Bugzilla::Metrics::Template; @@ -52,6 +52,8 @@ use File::Spec::Functions; use Safe; use Sys::Syslog qw(:DEFAULT); +use parent qw(Bugzilla::CPAN); + ##################################################################### # Constants ##################################################################### @@ -252,39 +254,6 @@ sub extensions { return $cache->{extensions}; } -sub feature { - my ($class, $feature_name) = @_; - return 0 unless CAN_HAS_FEATURE; - return 0 unless $class->has_feature($feature_name); - - my $cache = $class->process_cache; - my $feature = $cache->{cpan_meta}->feature($feature_name); - # Bugzilla expects this will also load all the modules.. so we have to do that. - # Later we should put a deprecation warning here, and favor calling has_feature(). - - return 1 if $cache->{feature_loaded}{$feature_name}; - my @modules = $feature->prereqs->merged_requirements->required_modules; - Module::Runtime::require_module($_) foreach @modules; - $cache->{feature_loaded}{$feature_name} = 1; - return 1; -} - -sub has_feature { - my ($class, $feature_name) = @_; - - return 0 unless CAN_HAS_FEATURE; - - my $cache = $class->process_cache; - return $cache->{feature}->{$feature_name} - if exists $cache->{feature}->{$feature_name}; - - my $meta = $cache->{cpan_meta} //= load_cpan_meta(); - my $feature = eval { $meta->feature($feature_name) } - or ThrowCodeError('invalid_feature', { feature => $feature_name }); - - return $cache->{feature}{$feature_name} = check_cpan_feature($feature)->{ok}; -} - sub cgi { return $_[0]->request_cache->{cgi} ||= new Bugzilla::CGI(); } -- cgit v1.2.3-24-g4f1b