Closed Bug 843457 Opened 11 years ago Closed 11 years ago

PROJECT environment variable is not honored when mod_perl is enabled

Categories

(Bugzilla :: Bugzilla-General, defect)

4.2.4
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.2

People

(Reporter: mike, Assigned: LpSolit)

References

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0
Build ID: 20130206152940

Steps to reproduce:

I upgraded my fully functional Bugzilla 4.0 instance to 4.2. I had a Bugzilla setup using the PROJECT variable setup as defined by the official documentation for multiple Bugzilla instances. I have verified that the PROJECT variable is passed from Apache to Bugzilla so this is not an Apache bug.

http://www.bugzilla.org/docs/4.2/en/html/multiple-bz-dbs.html


Actual results:

The PROJECT variable is not honored by "checksetup.pl" or any other part of Bugzilla. Checksetup.pl created a /etc/bugzilla/localhost instead of /etc/bugzilla/localhost.$PROJECT and is not looking at my $PROJECT template directory.


Expected results:

Same functionality as Bugzilla 4.0 in that it looks at /etc/bugzilla/localhost.$PROJECT and uses my $PROJECT template directory.
See also bug 467324
I found the root cause for this bug.

In Bugzilla/Constants.pm, bz_locations() is being memoize'd and this causes environment variables to not be passed in the first time Bugzilla is loaded. I'm too Perl-ignorant to come up with a fix as removing memoize breaks Bugzilla and I'm not familiar with how to set an environment variable from the BEGIN block. If I hardcode the PROJECT environment variable inside the BEGIN block things work as expected.

This makes sense as Bugzilla 4.0 did not memoize bz_locations().
Looks like a regression due to bug 576670. Per bug 576670 comment 1:

* I noticed that bz_locations was getting called a lot, and it's really a constant, so I Memoize'd it. This is safe to do because its contents will never change, even under mod_perl.

But if PROJECT is set, the contents can change.
Status: UNCONFIRMED → NEW
Depends on: 576670
Ever confirmed: true
Keywords: regression
Instead of using Memoize, we could cache bz_locations(). I suppose Bugzilla->request_cache would be a good place for it.
Target Milestone: --- → Bugzilla 4.4
http://perldoc.perl.org/Memoize.html#CAVEATS states that:

"Do not memoize a function whose behavior depends on program state other than its own arguments, such as global variables"

But bz_locations() depends on $ENV{'PROJECT'}. IMO, this is severe enough to be backported to 4.2.8.
Assignee: general → LpSolit
Status: NEW → ASSIGNED
Flags: blocking4.4.2+
Flags: blocking4.2.8+
Summary: PROJECT environment variable is not honored → PROJECT environment variable is not honored when mod_perl is enabled
Target Milestone: Bugzilla 4.4 → Bugzilla 4.2
Attached patch patch, v1 (obsolete) — Splinter Review
We cannot use Bugzilla->request_cache nor ->process_cache, because Bugzilla::Constants is called early in the installation process, when these caches are not yet available.
Attachment #831511 - Flags: review?(glob)
Attached patch patch, v1.1Splinter Review
I forgot to remove the global variable from _bz_locations().
Attachment #831511 - Attachment is obsolete: true
Attachment #831511 - Flags: review?(glob)
Attachment #831513 - Flags: review?(glob)
Comment on attachment 831513 [details] [diff] [review]
patch, v1.1

r=glob, nice
Attachment #831513 - Flags: review?(glob) → review+
Flags: approval4.4+
Flags: approval4.2+
Flags: approval+
I can confirm the patch works for me. Thanks, Frédéric!
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/Constants.pm
Committed revision 8810.

Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.4/
modified Bugzilla/Constants.pm
Committed revision 8636.

Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.2/
modified Bugzilla/Constants.pm
Committed revision 8237.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Added to relnotes for 4.4.2.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: