summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-06-30 01:49:55 +0200
committermkanat%bugzilla.org <>2006-06-30 01:49:55 +0200
commita0196b5d1ed38b7bf7f0783c1c865d6642f2e2b2 (patch)
treec69b87d1aba4ed1d77ec33abdaccafe249bd735b
parent38b17a8f16b21bb3dae4f1e6c01c84a5adc5d38f (diff)
downloadbugzilla-a0196b5d1ed38b7bf7f0783c1c865d6642f2e2b2.tar.gz
bugzilla-a0196b5d1ed38b7bf7f0783c1c865d6642f2e2b2.tar.xz
Bug 342121: Remove usage of Config qw(:locations) in favor of Constants::bz_locations()
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=justdave
-rw-r--r--Bugzilla/Attachment.pm6
-rw-r--r--Bugzilla/BugMail.pm4
-rw-r--r--Bugzilla/Config.pm48
-rw-r--r--Bugzilla/Hook.pm3
-rw-r--r--Bugzilla/Mailer.pm5
-rw-r--r--Bugzilla/Template.pm9
-rw-r--r--Bugzilla/Template/Plugin/Hook.pm3
-rw-r--r--Bugzilla/Update.pm8
-rwxr-xr-xchecksetup.pl31
9 files changed, 49 insertions, 68 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index a7961d764..78d326049 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -47,9 +47,10 @@ that users upload to the Bugzilla server.
=cut
+use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Flag;
-use Bugzilla::Config qw(:locations Param);
+use Bugzilla::Config;
use Bugzilla::User;
use Bugzilla::Util qw(trick_taint);
@@ -384,7 +385,7 @@ sub _get_local_filename {
my $self = shift;
my $hash = ($self->id % 100) + 100;
$hash =~ s/.*(\d\d)$/group.$1/;
- return "$attachdir/$hash/attachment." . $self->id;
+ return bz_locations()->{'attachdir'} . "/$hash/attachment." . $self->id;
}
sub _validate_filename {
@@ -700,6 +701,7 @@ sub insert_attachment_for_bug {
# If the file is to be stored locally, stream the file from the webserver
# to the local file without reading it into a local variable.
if ($cgi->param('bigfile')) {
+ my $attachdir = bz_locations()->{'attachdir'};
my $fh = $cgi->upload('data');
my $hash = ($attachid % 100) + 100;
$hash =~ s/.*(\d\d)$/group.$1/;
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index ef432c1e6..7c8aee1ba 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -35,7 +35,7 @@ package Bugzilla::BugMail;
use Bugzilla::Error;
use Bugzilla::User;
use Bugzilla::Constants;
-use Bugzilla::Config qw(:DEFAULT $datadir);
+use Bugzilla::Config;
use Bugzilla::Util;
use Bugzilla::Bug;
use Bugzilla::Product;
@@ -62,7 +62,7 @@ my %rel_names = (REL_ASSIGNEE , "AssignedTo",
my %nomail;
# This is run when we load the package
-if (open(NOMAIL, '<', "$datadir/nomail")) {
+if (open(NOMAIL, '<', bz_locations->{'datadir'} . "/nomail")) {
while (<NOMAIL>) {
$nomail{trim($_)} = 1;
}
diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm
index cb20fad24..a1c4b1f25 100644
--- a/Bugzilla/Config.pm
+++ b/Bugzilla/Config.pm
@@ -33,43 +33,7 @@ package Bugzilla::Config;
use strict;
use base qw(Exporter);
-
-# Under mod_perl, get this from a .htaccess config variable,
-# and/or default from the current 'real' dir
-# At some stage after this, it may be possible for these dir locations
-# to go into localconfig. localconfig can't be specified in a config file,
-# except possibly with mod_perl. If you move localconfig, you need to change
-# the define here.
-# $libpath is really only for mod_perl; its not yet possible to move the
-# .pms elsewhere.
-# $webdotdir must be in the webtree somewhere. Even if you use a local dot,
-# we output images to there. Also, if $webdot dir is not relative to the
-# bugzilla root directory, you'll need to change showdependencygraph.cgi to
-# set image_url to the correct location.
-# The script should really generate these graphs directly...
-# Note that if $libpath is changed, some stuff will break, notably dependency
-# graphs (since the path will be wrong in the HTML). This will be fixed at
-# some point.
-
-# constant paths
-our $libpath = '.';
-our $templatedir = "$libpath/template";
-
-# variable paths
-our $project;
-our $localconfig;
-our $datadir;
-if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) {
- $project = $1;
- $localconfig = "$libpath/localconfig.$project";
- $datadir = "$libpath/data/$project";
-} else {
- $localconfig = "$libpath/localconfig";
- $datadir = "$libpath/data";
-}
-our $attachdir = "$datadir/attachments";
-our $webdotdir = "$datadir/webdot";
-our $extensionsdir = "$libpath/extensions";
+use Bugzilla::Constants;
our @parampanels = ();
@@ -84,11 +48,9 @@ our @parampanels = ();
admin => [qw(UpdateParams SetParam WriteParams)],
db => [qw($db_driver $db_host $db_port $db_name $db_user $db_pass $db_sock)],
localconfig => [qw($cvsbin $interdiffbin $diffpath $webservergroup)],
- locations => [qw($libpath $localconfig $attachdir $datadir $templatedir
- $webdotdir $project $extensionsdir)],
params => [qw(@parampanels)],
);
-Exporter::export_ok_tags('admin', 'db', 'localconfig', 'locations', 'params');
+Exporter::export_ok_tags('admin', 'db', 'localconfig', 'params');
# Bugzilla version
$Bugzilla::Config::VERSION = "2.23.1+";
@@ -106,10 +68,13 @@ use vars qw(@param_list);
}
# INITIALISATION CODE
+# Perl throws a warning if we use bz_locations() directly after do.
+my $localconfig = bz_locations()->{'localconfig'};
do $localconfig;
my %params;
# Load in the param definitions
sub _load_params {
+ my $libpath = bz_locations()->{'libpath'};
foreach my $item ((glob "$libpath/Bugzilla/Config/*.pm")) {
$item =~ m#/([^/]+)\.pm$#;
my $module = $1;
@@ -265,6 +230,7 @@ sub UpdateParams {
sub WriteParams {
require Data::Dumper;
+ my $datadir = bz_locations()->{'datadir'};
# This only has an affect for Data::Dumper >= 2.12 (ie perl >= 5.8.0)
# Its just cosmetic, though, so that doesn't matter
@@ -294,7 +260,7 @@ sub WriteParams {
sub ChmodDataFile {
my ($file, $mask) = @_;
my $perm = 0770;
- if ((stat($datadir))[2] & 0002) {
+ if ((stat(bz_locations()->{'datadir'}))[2] & 0002) {
$perm = 0777;
}
$perm = $perm & $mask;
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index 9d8059478..8ce1482c1 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -22,6 +22,7 @@
package Bugzilla::Hook;
+use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
@@ -32,7 +33,7 @@ sub process {
trick_taint($name);
# get a list of all extensions
- my @extensions = glob($Bugzilla::Config::extensionsdir."/*");
+ my @extensions = glob(bz_locations()->{'extensionsdir'} . "/*");
# check each extension to see if it uses the hook
# if so, invoke the extension source file:
diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm
index 05ef82149..ce3565368 100644
--- a/Bugzilla/Mailer.pm
+++ b/Bugzilla/Mailer.pm
@@ -37,7 +37,7 @@ use base qw(Exporter);
@Bugzilla::Mailer::EXPORT = qw(MessageToMTA);
use Bugzilla::Constants;
-use Bugzilla::Config qw(:DEFAULT $datadir);
+use Bugzilla::Config;
use Bugzilla::Util;
use Mail::Header;
@@ -99,7 +99,8 @@ sub MessageToMTA {
}
my $mailer = new Mail::Mailer Param("mail_delivery_method"), @args;
if (Param("mail_delivery_method") eq "testfile") {
- $Mail::Mailer::testfile::config{outfile} = "$datadir/mailer.testfile";
+ $Mail::Mailer::testfile::config{outfile} =
+ bz_locations()->{'datadir'} . '/mailer.testfile';
}
$mailer->open($headers->header_hashref);
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 1fcc867b5..59cf02dc4 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -35,7 +35,7 @@ package Bugzilla::Template;
use strict;
use Bugzilla::Constants;
-use Bugzilla::Config qw(:DEFAULT $templatedir $datadir $project);
+use Bugzilla::Config;
use Bugzilla::Util;
use Bugzilla::User;
use Bugzilla::Error;
@@ -110,6 +110,9 @@ sub getTemplateIncludePath {
if ($template_include_path) {
return $template_include_path;
}
+ my $templatedir = bz_locations()->{'templatedir'};
+ my $project = bz_locations()->{'project'};
+
my $languages = trim(Param('languages'));
if (not ($languages =~ /,/)) {
if ($project) {
@@ -159,7 +162,7 @@ sub getTemplateIncludePath {
}
# add in extension template directories:
- my @extensions = glob($Bugzilla::Config::extensionsdir."/*");
+ my @extensions = glob(bz_locations()->{'extensionsdir'} . "/*");
foreach my $extension (@extensions) {
trick_taint($extension); # since this comes right from the filesystem
# we have bigger issues if it is insecure
@@ -533,7 +536,7 @@ sub create {
PRE_CHOMP => 1,
TRIM => 1,
- COMPILE_DIR => "$datadir/template",
+ COMPILE_DIR => bz_locations()->{'datadir'} . "/template",
# Initialize templates (f.e. by loading plugins like Hook).
PRE_PROCESS => "global/initialize.none.tmpl",
diff --git a/Bugzilla/Template/Plugin/Hook.pm b/Bugzilla/Template/Plugin/Hook.pm
index 7ff707fc1..c2e1626ef 100644
--- a/Bugzilla/Template/Plugin/Hook.pm
+++ b/Bugzilla/Template/Plugin/Hook.pm
@@ -26,6 +26,7 @@ package Bugzilla::Template::Plugin::Hook;
use strict;
use Bugzilla::Config;
+use Bugzilla::Constants;
use Bugzilla::Template;
use Bugzilla::Util;
use Bugzilla::Error;
@@ -64,7 +65,7 @@ sub process {
my $type = $2;
# munge the filename to create the extension hook filename:
my $extensiontemplate = $subpath.'/'.$templatename.'-'.$hook_name.'.'.$type.'.tmpl';
- my @extensions = glob($Bugzilla::Config::extensionsdir."/*");
+ my @extensions = glob(bz_locations()->{'extensionsdir'} . "/*");
my @usedlanguages = getLanguages();
foreach my $extension (@extensions) {
foreach my $language (@usedlanguages) {
diff --git a/Bugzilla/Update.pm b/Bugzilla/Update.pm
index a672bd8bb..1aef2bf17 100644
--- a/Bugzilla/Update.pm
+++ b/Bugzilla/Update.pm
@@ -18,10 +18,10 @@ package Bugzilla::Update;
use strict;
-use Bugzilla::Config qw($datadir);
+use Bugzilla::Constants;
use constant REMOTE_FILE => 'http://updates.bugzilla.org/bugzilla-update.xml';
-use constant LOCAL_FILE => "/bugzilla-update.xml"; # Relative to $datadir.
+use constant LOCAL_FILE => "/bugzilla-update.xml"; # Relative to datadir.
use constant TIME_INTERVAL => 604800; # Default is one week, in seconds.
use constant TIMEOUT => 5; # Number of seconds before timeout.
@@ -34,7 +34,7 @@ sub get_notifications {
eval("require XML::Twig");
return if $@;
- my $local_file = $datadir . LOCAL_FILE;
+ my $local_file = bz_locations()->{'datadir'} . LOCAL_FILE;
# Update the local XML file if this one doesn't exist or if
# the last modification time (stat[9]) is older than TIME_INTERVAL.
if (!-e $local_file || (time() - (stat($local_file))[9] > TIME_INTERVAL)) {
@@ -127,7 +127,7 @@ sub _synchronize_data {
eval("require LWP::UserAgent");
return if $@;
- my $local_file = $datadir . LOCAL_FILE;
+ my $local_file = bz_locations()->{'datadir'} . LOCAL_FILE;
my $ua = LWP::UserAgent->new();
$ua->timeout(TIMEOUT);
diff --git a/checksetup.pl b/checksetup.pl
index d60647295..349ac0b46 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -510,7 +510,7 @@ BEGIN {
$::ENV{'PATH'} = $env;
require Bugzilla::Config;
- import Bugzilla::Config qw(:DEFAULT :admin :locations);
+ import Bugzilla::Config qw(:DEFAULT :admin);
}
# 12/17/00 justdave@syndicomm.com - removed declarations of the localconfig
@@ -550,6 +550,7 @@ BEGIN {
print "Checking user setup ...\n" unless $silent;
$@ = undef;
+my $localconfig = bz_locations()->{'localconfig'};
do $localconfig;
if ($@) { # capture errors in localconfig, bug 97290
print STDERR <<EOT;
@@ -582,7 +583,7 @@ sub LocalVar
my ($name, $definition) = @_;
return if LocalVarExists($name); # if localconfig declared it, we're done.
$newstuff .= " " . $name;
- open FILE, '>>', $localconfig;
+ open FILE, '>>', bz_locations()->{'localconfig'};
print FILE ($answer{$name} or $definition), "\n\n";
close FILE;
}
@@ -803,7 +804,8 @@ if (LocalVarExists('mysqlpath')) {
if ($newstuff ne "") {
print "\nThis version of Bugzilla contains some variables that you may \n",
"want to change and adapt to your local settings. Please edit the\n",
- "file '$localconfig' and rerun checksetup.pl\n\n",
+ "file " . bz_locations()->{'localconfig'} ." and rerun ",
+ "checksetup.pl\n\n",
"The following variables are new to localconfig since you last ran\n",
"checksetup.pl: $newstuff\n\n";
exit;
@@ -938,6 +940,7 @@ if ($my_db_check) {
# Try to create the DB, and if we fail print an error.
if (!eval { $dbh->do("CREATE DATABASE $my_db_name") }) {
my $error = $dbh->errstr;
+ my $localconfig = bz_locations()->{'localconfig'};
die <<"EOF"
The '$my_db_name' database could not be created. The error returned was:
@@ -1048,7 +1051,7 @@ while (my ($table, $values) = each %$enum_values) {
#
# Create initial --DATA-- directory and make the initial empty files there:
#
-
+my $datadir = bz_locations()->{'datadir'};
unless (-d $datadir && -e "$datadir/nomail") {
print "Creating data directory ($datadir) ...\n";
# permissions for non-webservergroup are fixed later on
@@ -1058,13 +1061,14 @@ unless (-d $datadir && -e "$datadir/nomail") {
open FILE, '>>', "$datadir/mail"; close FILE;
}
-
+my $attachdir = bz_locations->{'attachdir'};
unless (-d $attachdir) {
print "Creating local attachments directory ...\n";
# permissions for non-webservergroup are fixed later on
mkdir $attachdir, 0770;
}
+my $extensionsdir = bz_locations->{'extensionsdir'};
# ZLL: 2005-08-20 Create extensions/ if it does not already exist:
unless (-d $extensionsdir) {
print "Creating extensions directory ($extensionsdir) ...\n";
@@ -1161,6 +1165,7 @@ unless (-d "$datadir/mining") {
mkdir "$datadir/mining", 0700;
}
+my $webdotdir = bz_locations()->{'webdotdir'};
unless (-d "$webdotdir") {
# perms/ownership are fixed up later
mkdir "$webdotdir", 0700;
@@ -1277,6 +1282,7 @@ END
chmod $fileperm, "$datadir/.htaccess";
}
# Ditto for the template dir
+ my $templatedir = bz_locations()->{'templatedir'};
if (!-e "$templatedir/.htaccess") {
print "Creating $templatedir/.htaccess...\n";
open HTACCESS, '>', "$templatedir/.htaccess";
@@ -1344,11 +1350,7 @@ END
}
}
-# Just to be sure ...
-unlink "$datadir/versioncache";
-
# Check for a new install
-
my $newinstall = !-e "$datadir/params";
# Remove parameters from the params file that no longer exist in Bugzilla,
@@ -1405,6 +1407,7 @@ if ($newinstall) {
# WriteParams will only write out still-valid entries
WriteParams();
+my $templatedir = bz_locations()->{'templatedir'};
unless ($switch{'no_templates'}) {
if (-e "$datadir/template") {
print "Removing existing compiled templates ...\n" unless $silent;
@@ -1579,7 +1582,8 @@ if ($^O !~ /MSWin32/i) {
fixPerms("$datadir/duplicates", $<, $webservergid, 027, 1);
fixPerms("$datadir/mining", $<, $webservergid, 027, 1);
fixPerms("$datadir/template", $<, $webservergid, 007, 1); # webserver will write to these
- fixPerms($attachdir, $<, $webservergid, 007, 1); # webserver will write to these
+ # webserver will write to attachdir.
+ fixPerms(bz_locations()->{'attachdir'}, $<, $webservergid, 007, 1);
fixPerms($webdotdir, $<, $webservergid, 007, 1);
fixPerms("$webdotdir/.htaccess", $<, $webservergid, 027);
fixPerms("$datadir/params", $<, $webservergid, 017);
@@ -4352,6 +4356,11 @@ EOF
NOTNULL => 1});
}
+if (-e "$datadir/versioncache") {
+ print "Removing versioncache...\n";
+ unlink "$datadir/versioncache";
+}
+
# If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment.
@@ -4778,8 +4787,6 @@ $dbh->do("UPDATE components " .
"SET initialowner = $adminuid " .
"WHERE initialowner = 0");
-unlink "$datadir/versioncache";
-
# Check if the default parameter for urlbase is still set, and if so, give
# notification that they should go and visit editparams.cgi