Bugzilla->error_mode( ERROR_MODE_WEBPAGE ) doesn't change Bugzilla->error_mode

RESOLVED FIXED in Bugzilla 4.4

Status

()

--
minor
RESOLVED FIXED
8 years ago
7 years ago

People

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

Tracking

4.1.1
Bugzilla 4.4
Bug Flags:
approval +

Details

Attachments

(1 attachment)

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0
Build Identifier: 4.1.1

This is very similar to bug #645427

sub error_mode {
...
    return $class->request_cache->{error_mode}
        || (i_am_cgi() ? ERROR_MODE_WEBPAGE : ERROR_MODE_DIE);
}

With ERROR_MODE_WEBPAGE the above return always ignores first part of the || expression because ERROR_MODE_WEBPAGE == 0.

Reproducible: Always

Steps to Reproduce:
From console app run Bugzilla->usage_mode( USAGE_MODE_BROWSER ) - this also attempts to change error_mode
Actual Results:  
Bugzilla->error_mode( ERROR_MODE_WEBPAGE ) doesn't change Bugzilla->usage_mode to ERROR_MODE_WEBPAGE

Expected Results:  
Bugzilla->error_mode( ERROR_MODE_WEBPAGE ) should change Bugzilla->usage_mode to ERROR_MODE_WEBPAGE
(Reporter)

Comment 1

8 years ago
In Expected/Actual Results of problem description Bugzilla->usage_mode should be read as Bugzilla->error_mode.

Comment 2

8 years ago
We should check "exists $class->request_cache->{error_mode}".
Status: UNCONFIRMED → NEW
Ever confirmed: true
Version: unspecified → 4.1.1

Updated

8 years ago
Severity: normal → minor

Updated

8 years ago
Whiteboard: [Good Intro Bug]
(Assignee)

Comment 3

7 years ago
Created attachment 617199 [details] [diff] [review]
V1

The return statement in the 'else' part could also be written without the 'else'. That is outside the last if.
Attachment #617199 - Flags: review?(mkanat)
Attachment #617199 - Flags: review?(LpSolit)

Comment 4

7 years ago
Comment on attachment 617199 [details] [diff] [review]
V1

>-    return $class->request_cache->{error_mode}
>-        || (i_am_cgi() ? ERROR_MODE_WEBPAGE : ERROR_MODE_DIE);
>+    if (exists($class->request_cache->{error_mode}) {

There is a missing closing parenthesis.


>+        return $class->request_cache->{error_mode};
>+    }
>+    else {
>+        return (i_am_cgi() ? ERROR_MODE_WEBPAGE : ERROR_MODE_DIE);
>+    }

As for bug 645427, I will add a comment about making the code cleaner once we require Perl 5.10.1. r=LpSolit
Attachment #617199 - Flags: review?(mkanat)
Attachment #617199 - Flags: review?(LpSolit)
Attachment #617199 - Flags: review+

Comment 5

7 years ago
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla.pm
Committed revision 8214.
Assignee: general → koosha.khajeh
Status: NEW → RESOLVED
Last Resolved: 7 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.