PROJECT environment variable is not honored when mod_perl is enabled

RESOLVED FIXED in Bugzilla 4.2



5 years ago
4 years ago


(Reporter: Michael Cronenworth, Assigned: Frédéric Buclin)



Bugzilla 4.2
Bug Flags:
approval +
approval4.4 +
blocking4.4.2 +
approval4.2 +
blocking4.2.8 +



(1 attachment, 1 obsolete attachment)



5 years ago
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.

Actual results:

The PROJECT variable is not honored by "" or any other part of Bugzilla. 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.

Comment 1

5 years ago
See also bug 467324

Comment 2

4 years ago
I found the root cause for this bug.

In Bugzilla/, 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().

Comment 3

4 years ago
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.
Depends on: 576670
Ever confirmed: true
Keywords: regression

Comment 4

4 years ago
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

Comment 5

4 years ago 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
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

Comment 6

4 years ago
Created attachment 831511 [details] [diff] [review]
patch, v1

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)

Comment 7

4 years ago
Created attachment 831513 [details] [diff] [review]
patch, v1.1

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+

Comment 9

4 years ago
I can confirm the patch works for me. Thanks, Frédéric!

Comment 10

4 years ago
Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 8810.

Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 8636.

Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 8237.
Last Resolved: 4 years ago
Resolution: --- → FIXED

Comment 11

4 years ago
Added to relnotes for 4.4.2.
You need to log in before you can comment on or make changes to this bug.