Closed Bug 645427 Opened 14 years ago Closed 13 years ago

Bugzilla->usage_mode( USAGE_MODE_BROWSER ) doesn't change Bugzilla->usage_mode

Categories

(Bugzilla :: Bugzilla-General, defect)

4.1.1
defect
Not set
minor

Tracking

()

RESOLVED FIXED
Bugzilla 4.4

People

(Reporter: yavor.nikolov7+bugzilla, Assigned: koosha.khajeh)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Build Identifier: 4.1.1 Bugzilla->usage_mode( Bugzilla::Constants->USAGE_MODE_BROWSER ) doesn't change Bugzilla->usage_mode to USAGE_MODE_BROWSER Reproducible: Always Steps to Reproduce: print( "USAGE_MODE_BROWSER: ", Bugzilla::Constants->USAGE_MODE_BROWSER, "\n" ); print( "USAGE_MODE_CMDLINE: ", Bugzilla::Constants->USAGE_MODE_CMDLINE, "\n" ); print( "usage_mode before change: ", Bugzilla->usage_mode, "\n" ); my $res1 = Bugzilla->usage_mode( Bugzilla::Constants->USAGE_MODE_BROWSER ); print( "usage_mode during change: ", $res1, "\n" ); print( "usage_mode after change: ", Bugzilla->usage_mode, "\n" ); Actual Results: USAGE_MODE_BROWSER: 0 USAGE_MODE_CMDLINE: 1 usage_mode before change: 1 usage_mode during change: 1 usage_mode after change: 1 Expected Results: USAGE_MODE_BROWSER: 0 USAGE_MODE_CMDLINE: 1 usage_mode before change: 1 usage_mode during change: 0 usage_mode after change: 0 Root cause is return statement in Bugzilla::usage_mode: return $class->request_cache->{usage_mode} || (i_am_cgi()? USAGE_MODE_BROWSER : USAGE_MODE_CMDLINE); When $class->request_cache->{usage_mode} == 0 first part of the || expression is always discarded.
Looking at usage_mode code of stable older releases - issues seems to exist since 3.2
Sorry... I meant since 3.4 (not 3.2)
We should probably check "exists $class->request_cache->{usage_mode}".
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: unspecified → 4.1.1
Oh, exists is a good idea, yeah.
Whiteboard: [Good Intro Bug]
Severity: normal → minor
Attached patch V1Splinter Review
Attachment #617193 - Flags: review?(mkanat)
Attachment #617193 - Flags: review?(LpSolit)
Comment on attachment 617193 [details] [diff] [review] V1 >+ if (exists($class->request_cache->{usage_mode})) { >+ return $class->request_cache->{usage_mode}; >+ } >+ else { >+ return (i_am_cgi()? USAGE_MODE_BROWSER : USAGE_MODE_CMDLINE); >+ } Once we require Perl 5.10.1, all this code can simply be replaced by: return $class->request_cache->{usage_mode} // (i_am_cgi()? USAGE_MODE_BROWSER : USAGE_MODE_CMDLINE); I will add a comment above this code so that we remember to do it in Bugzilla 4.6. r=LpSolit
Attachment #617193 - Flags: review?(mkanat)
Attachment #617193 - Flags: review?(LpSolit)
Attachment #617193 - Flags: review+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/ modified Bugzilla.pm Committed revision 8213.
Assignee: general → koosha.khajeh
Status: NEW → RESOLVED
Closed: 13 years ago
Depends on: 655477
Flags: approval+
Resolution: --- → FIXED
Whiteboard: [Good Intro Bug]
Target Milestone: --- → Bugzilla 4.4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: