summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-23 17:25:43 +0200
committerGitHub <noreply@github.com>2018-07-23 17:25:43 +0200
commit345e686485e484e087ea58c988e4831209c39554 (patch)
tree6888ff14ec3d34cfe21d64d520421ba94918a25b /Bugzilla
parente8c0dfe232ce1efe78f8dd7cf6b78c24b96786e8 (diff)
downloadbugzilla-345e686485e484e087ea58c988e4831209c39554.tar.gz
bugzilla-345e686485e484e087ea58c988e4831209c39554.tar.xz
Bug 1476841 - Various code cleanups ahead of the Mojolicious patch
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/CPAN.pm2
-rw-r--r--Bugzilla/Constants.pm9
-rw-r--r--Bugzilla/DaemonControl.pm19
-rw-r--r--Bugzilla/Template.pm11
4 files changed, 16 insertions, 25 deletions
diff --git a/Bugzilla/CPAN.pm b/Bugzilla/CPAN.pm
index d765d2901..1b6fb93b9 100644
--- a/Bugzilla/CPAN.pm
+++ b/Bugzilla/CPAN.pm
@@ -103,7 +103,7 @@ sub feature {
my $meta = $class->cpan_meta;
my $feature = $meta->feature($feature_name);
my @modules = $feature->prereqs->merged_requirements(['runtime'], ['requires'])->required_modules;
- Module::Runtime::require_module($_) foreach @modules;
+ Module::Runtime::require_module($_) foreach grep { !/^Test::Taint$/ } @modules;
return $FEATURE_LOADED{$feature_name} = 1;
}
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 3aa7b0fa4..185a30390 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -15,6 +15,7 @@ use base qw(Exporter);
# For bz_locations
use File::Basename;
+use Cwd qw(realpath);
use Memoize;
@Bugzilla::Constants::EXPORT = qw(
@@ -644,12 +645,8 @@ sub _bz_locations {
# directory under both mod_cgi and mod_perl. We call dirname twice
# to get the name of the directory above the "Bugzilla/" directory.
#
- # Calling dirname twice like that won't work on VMS or AmigaOS
- # but I doubt anybody runs Bugzilla on those.
- #
- # On mod_cgi this will be a relative path. On mod_perl it will be an
- # absolute path.
- my $libpath = dirname(dirname($INC{'Bugzilla/Constants.pm'}));
+ # Always use an absolute path, based on the location of this file.
+ my $libpath = realpath(dirname(dirname(__FILE__)));
# We have to detaint $libpath, but we can't use Bugzilla::Util here.
$libpath =~ /(.*)/;
$libpath = $1;
diff --git a/Bugzilla/DaemonControl.pm b/Bugzilla/DaemonControl.pm
index 2c6df1b87..6ff883af0 100644
--- a/Bugzilla/DaemonControl.pm
+++ b/Bugzilla/DaemonControl.pm
@@ -14,7 +14,7 @@ use Bugzilla::Logging;
use Bugzilla::Constants qw(bz_locations);
use Cwd qw(realpath);
use English qw(-no_match_vars $PROGRAM_NAME);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
use Future::Utils qw(repeat try_repeat);
use Future;
use IO::Async::Loop;
@@ -40,12 +40,11 @@ our %EXPORT_TAGS = (
utils => [qw(catch_signal on_exception on_finish)],
);
-use constant {
- JOBQUEUE_BIN => realpath( catfile( bz_locations->{cgi_path}, 'jobqueue.pl' ) ),
- CEREAL_BIN => realpath( catfile( bz_locations->{cgi_path}, 'scripts', 'cereal.pl' ) ),
- HTTPD_BIN => '/usr/sbin/httpd',
- HTTPD_CONFIG => realpath( catfile( bz_locations->{confdir}, 'httpd.conf' ) ),
-};
+my $BUGZILLA_DIR = bz_locations->{cgi_path};
+my $JOBQUEUE_BIN = catfile( $BUGZILLA_DIR, 'jobqueue.pl' );
+my $CEREAL_BIN = catfile( $BUGZILLA_DIR, 'scripts', 'cereal.pl' );
+my $HTTPD_BIN = '/usr/sbin/httpd';
+my $HTTPD_CONFIG = catfile( bz_locations->{confdir}, 'httpd.conf' );
sub catch_signal {
my ($name, @done) = @_;
@@ -76,7 +75,7 @@ sub run_cereal {
my $loop = IO::Async::Loop->new;
my $exit_f = $loop->new_future;
my $cereal = IO::Async::Process->new(
- command => [CEREAL_BIN],
+ command => [$CEREAL_BIN],
on_finish => on_finish($exit_f),
on_exception => on_exception( 'cereal', $exit_f ),
);
@@ -103,7 +102,7 @@ sub run_httpd {
# we have to setsid() to make a new process group
# or else apache will kill its parent.
setsid();
- my @command = ( HTTPD_BIN, '-DFOREGROUND', '-f' => HTTPD_CONFIG, @args );
+ my @command = ( $HTTPD_BIN, '-DFOREGROUND', '-f' => $HTTPD_CONFIG, @args );
exec @command
or die "failed to exec $command[0] $!";
},
@@ -122,7 +121,7 @@ sub run_jobqueue {
my $loop = IO::Async::Loop->new;
my $exit_f = $loop->new_future;
my $jobqueue = IO::Async::Process->new(
- command => [ JOBQUEUE_BIN, 'start', '-f', '-d', @args ],
+ command => [ $JOBQUEUE_BIN, 'start', '-f', '-d', @args ],
on_finish => on_finish($exit_f),
on_exception => on_exception( 'httpd', $exit_f ),
);
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 8cf91052e..299734d64 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -565,13 +565,8 @@ sub create {
PRE_CHOMP => 1,
TRIM => 1,
- # Bugzilla::Template::Plugin::Hook uses the absolute (in mod_perl)
- # or relative (in mod_cgi) paths of hook files to explicitly compile
- # a specific file. Also, these paths may be absolute at any time
- # if a packager has modified bz_locations() to contain absolute
- # paths.
ABSOLUTE => 1,
- RELATIVE => $ENV{MOD_PERL} ? 0 : 1,
+ RELATIVE => 0,
# Only use an on-disk template cache if we're running as the web
# server. This ensures the permissions of the cache remain correct.
@@ -584,7 +579,7 @@ sub create {
# Initialize templates (f.e. by loading plugins like Hook).
PRE_PROCESS => ["global/initialize.none.tmpl"],
- ENCODING => Bugzilla->params->{'utf8'} ? 'UTF-8' : undef,
+ ENCODING => 'UTF-8',
# Functions for processing text within templates in various ways.
# IMPORTANT! When adding a filter here that does not override a
@@ -1042,7 +1037,7 @@ sub create {
# under mod_perl, use a provider (template loader) that preloads all templates into memory
my $provider_class
- = $ENV{MOD_PERL}
+ = $opts{preload}
? 'Bugzilla::Template::PreloadProvider'
: 'Template::Provider';