From f5d288458658b7fde5b8ef2fb03a8701e01828fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Wed, 13 Nov 2013 16:17:12 +0100 Subject: [PATCH] Bug 843457: PROJECT environment variable is not honored when mod_perl is enabled r/a=glob --- Bugzilla/Constants.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index da12e03672..191133768b 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -592,6 +592,13 @@ use constant AUDIT_CREATE => '__create__'; use constant AUDIT_REMOVE => '__remove__'; 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. # 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 @@ -608,12 +615,13 @@ sub bz_locations { $libpath =~ /(.*)/; $libpath = $1; - my ($project, $localconfig, $datadir); - if ($ENV{'PROJECT'} && $ENV{'PROJECT'} =~ /^(\w+)$/) { + my ($localconfig, $datadir); + if ($project && $project =~ /^(\w+)$/) { $project = $1; $localconfig = "localconfig.$project"; $datadir = "data/$project"; } else { + $project = undef; $localconfig = "localconfig"; $datadir = "data"; } @@ -648,6 +656,6 @@ sub bz_locations { # This makes us not re-compute all the bz_locations data every time it's # called. -BEGIN { memoize('bz_locations') }; +BEGIN { memoize('_bz_locations') }; 1; -- 2.47.2