Commit f5d28845 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 843457: PROJECT environment variable is not honored when mod_perl is enabled

r/a=glob
parent 1aabf206
...@@ -592,6 +592,13 @@ use constant AUDIT_CREATE => '__create__'; ...@@ -592,6 +592,13 @@ use constant AUDIT_CREATE => '__create__';
use constant AUDIT_REMOVE => '__remove__'; use constant AUDIT_REMOVE => '__remove__';
sub bz_locations { sub bz_locations {
# Force memoize() to re-compute data per project, to avoid
# sharing the same data across different installations.
return _bz_locations($ENV{'PROJECT'});
}
sub _bz_locations {
my $project = shift;
# We know that Bugzilla/Constants.pm must be in %INC at this point. # We know that Bugzilla/Constants.pm must be in %INC at this point.
# So the only question is, what's the name of the directory # So the only question is, what's the name of the directory
# above it? This is the most reliable way to get our current working # above it? This is the most reliable way to get our current working
...@@ -608,12 +615,13 @@ sub bz_locations { ...@@ -608,12 +615,13 @@ sub bz_locations {
$libpath =~ /(.*)/; $libpath =~ /(.*)/;
$libpath = $1; $libpath = $1;
my ($project, $localconfig, $datadir); my ($localconfig, $datadir);
if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) { if ($project && $project =~ /^(\w+)$/) {
$project = $1; $project = $1;
$localconfig = "localconfig.$project"; $localconfig = "localconfig.$project";
$datadir = "data/$project"; $datadir = "data/$project";
} else { } else {
$project = undef;
$localconfig = "localconfig"; $localconfig = "localconfig";
$datadir = "data"; $datadir = "data";
} }
...@@ -648,6 +656,6 @@ sub bz_locations { ...@@ -648,6 +656,6 @@ sub bz_locations {
# This makes us not re-compute all the bz_locations data every time it's # This makes us not re-compute all the bz_locations data every time it's
# called. # called.
BEGIN { memoize('bz_locations') }; BEGIN { memoize('_bz_locations') };
1; 1;
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