summaryrefslogtreecommitdiffstats
path: root/Bugzilla.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2016-07-01 05:32:40 +0200
committerDylan William Hardison <dylan@hardison.net>2016-09-12 19:03:27 +0200
commite6bf4cacb10f86077fe898349485f5c7ab9fb4b6 (patch)
tree24a4973f71f38e0cd7788a25817142ab6c05ed3e /Bugzilla.pm
parent591e2dabe136e9a9190f3a67c89349cb794ae9a9 (diff)
downloadbugzilla-e6bf4cacb10f86077fe898349485f5c7ab9fb4b6.tar.gz
bugzilla-e6bf4cacb10f86077fe898349485f5c7ab9fb4b6.tar.xz
Bug 1283930 - Add Makefile.PL & local/lib/perl5 support to bmo/master + local symlink to data/ directory
Diffstat (limited to 'Bugzilla.pm')
-rw-r--r--Bugzilla.pm90
1 files changed, 37 insertions, 53 deletions
diff --git a/Bugzilla.pm b/Bugzilla.pm
index 56bbb5c15..72192d41a 100644
--- a/Bugzilla.pm
+++ b/Bugzilla.pm
@@ -1,30 +1,15 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code is the Bugzilla Bug Tracking System.
-#
-# The Initial Developer of the Original Code is Netscape Communications
-# Corporation. Portions created by Netscape are
-# Copyright (C) 1998 Netscape Communications Corporation. All
-# Rights Reserved.
-#
-# Contributor(s): Bradley Baetz <bbaetz@student.usyd.edu.au>
-# Erik Stambaugh <erik@dasbistro.com>
-# A. Karl Kornel <karl@kornel.name>
-# Marc Schumann <wurblzap@gmail.com>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
package Bugzilla;
+use 5.10.1;
use strict;
+use warnings;
# We want any compile errors to get to the browser, if possible.
BEGIN {
@@ -47,8 +32,8 @@ use Bugzilla::Field;
use Bugzilla::Flag;
use Bugzilla::Hook;
use Bugzilla::Install::Localconfig qw(read_localconfig);
-use Bugzilla::Install::Requirements qw(OPTIONAL_MODULES);
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;
@@ -253,7 +238,7 @@ sub extensions {
my $extension = $package->new();
if ($extension->enabled) {
push(@extensions, $extension);
- }
+ }
}
$cache->{extensions} = \@extensions;
}
@@ -261,37 +246,36 @@ sub extensions {
}
sub feature {
- my ($class, $feature) = @_;
- my $cache = $class->request_cache;
- return $cache->{feature}->{$feature}
- if exists $cache->{feature}->{$feature};
-
- my $feature_map = $cache->{feature_map};
- if (!$feature_map) {
- foreach my $package (@{ OPTIONAL_MODULES() }) {
- foreach my $f (@{ $package->{feature} }) {
- $feature_map->{$f} ||= [];
- push(@{ $feature_map->{$f} }, $package->{module});
- }
- }
- $cache->{feature_map} = $feature_map;
- }
+ 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;
+}
- if (!$feature_map->{$feature}) {
- ThrowCodeError('invalid_feature', { feature => $feature });
- }
+sub has_feature {
+ my ($class, $feature_name) = @_;
- my $success = 1;
- foreach my $module (@{ $feature_map->{$feature} }) {
- # We can't use a string eval and "use" here (it kills Template-Toolkit,
- # see https://rt.cpan.org/Public/Bug/Display.html?id=47929), so we have
- # to do a block eval.
- $module =~ s{::}{/}g;
- $module .= ".pm";
- eval { require $module; 1; } or $success = 0;
- }
- $cache->{feature}->{$feature} = $success;
- return $success;
+ 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 {