=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);
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 {
# 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/;
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;
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;
}
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 = ();
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+";
}
# 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;
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
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;
package Bugzilla::Hook;
+use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
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:
@Bugzilla::Mailer::EXPORT = qw(MessageToMTA);
use Bugzilla::Constants;
-use Bugzilla::Config qw(:DEFAULT $datadir);
+use Bugzilla::Config;
use Bugzilla::Util;
use Mail::Header;
}
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);
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;
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) {
}
# 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
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",
use strict;
use Bugzilla::Config;
+use Bugzilla::Constants;
use Bugzilla::Template;
use Bugzilla::Util;
use Bugzilla::Error;
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) {
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.
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)) {
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);
$::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
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;
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;
}
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;
# 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:
#
# 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
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";
mkdir "$datadir/mining", 0700;
}
+my $webdotdir = bz_locations()->{'webdotdir'};
unless (-d "$webdotdir") {
# perms/ownership are fixed up later
mkdir "$webdotdir", 0700;
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";
}
}
-# 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,
# 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;
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);
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.
"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