Commit 6dde50de authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 342744: bz_locations should return absolute paths for mod_perl

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, r=justdave, a=justdave
parent 3a6d6e9f
...@@ -32,6 +32,9 @@ package Bugzilla::Constants; ...@@ -32,6 +32,9 @@ package Bugzilla::Constants;
use strict; use strict;
use base qw(Exporter); use base qw(Exporter);
# For bz_locations
use File::Basename;
@Bugzilla::Constants::EXPORT = qw( @Bugzilla::Constants::EXPORT = qw(
BUGZILLA_VERSION BUGZILLA_VERSION
...@@ -295,46 +298,50 @@ use constant DB_MODULE => { ...@@ -295,46 +298,50 @@ use constant DB_MODULE => {
name => 'PostgreSQL'}, name => 'PostgreSQL'},
}; };
# 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.
sub bz_locations { sub bz_locations {
my $libpath = '.'; # We know that Bugzilla/Constants.pm must be in %INC at this point.
my $project; # So the only question is, what's the name of the directory
my $localconfig; # above it? This is the most reliable way to get our current working
my $datadir; # 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'}));
# We have to detaint $libpath, but we can't use Bugzilla::Util here.
$libpath =~ /(.*)/;
$libpath = $1;
my ($project, $localconfig, $datadir);
if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) { if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) {
$project = $1; $project = $1;
$localconfig = "$libpath/localconfig.$project"; $localconfig = "localconfig.$project";
$datadir = "$libpath/data/$project"; $datadir = "data/$project";
} else { } else {
$localconfig = "$libpath/localconfig"; $localconfig = "localconfig";
$datadir = "$libpath/data"; $datadir = "data";
} }
# Returns a hash of paths. # We have to return absolute paths for mod_perl.
# That means that if you modify these paths, they must be absolute paths.
return { return {
'libpath' => $libpath, 'libpath' => $libpath,
'templatedir' => "$libpath/template", 'templatedir' => "$libpath/template",
'project' => $project, 'project' => $project,
'localconfig' => $localconfig, 'localconfig' => "$libpath/$localconfig",
'datadir' => $datadir, 'datadir' => "$libpath/$datadir",
'attachdir' => "$datadir/attachments", 'attachdir' => "$libpath/$datadir/attachments",
'webdotdir' => "$datadir/webdot", # $webdotdir must be in the webtree somewhere. Even if you use a
'extensionsdir' => "$libpath/extensions" # local dot, we output images to there. Also, if $webdotdir 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...
'webdotdir' => "$libpath/$datadir/webdot",
'extensionsdir' => "$libpath/extensions",
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment