Closed Bug 600598 Opened 14 years ago Closed 14 years ago

"Can't call method "bug_list" on unblessed reference" error thrown when editing a bug which is in the BUGLIST cookie but not in a recent saved search, with action="next_bug"

Categories

(Bugzilla :: Creating/Changing Bugs, defect)

3.7.3
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.0

People

(Reporter: bugzilla, Assigned: LpSolit)

References

Details

(Keywords: regression)

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.24 Safari/534.7
Build Identifier: 4.0 branch, revision 7417

I've been running revision 7417 of the 4.0 branch of Bugzilla for a few days, and a couple of users have reported receiving Software error messages like this:


Software error:

Can't call method "bug_list" on unblessed reference at
/export/apps01/www/html/bugzilla/process_bug.cgi line 196, <DATA> line 522.

Reproducible: Always

Steps to Reproduce:
I haven't found the sequence of steps required to reproduce this error yet.
Actual Results:  
The above error

Expected Results:  
No error :-)

The relevant code in process_bug.cgi is:

    if ($action eq 'next_bug') {
        my $bug_list_obj = $user->recent_search_for($first_bug);
        my @bug_list = $bug_list_obj ? @{$bug_list_obj->bug_list} : ();

... so I take that to mean that $user->recent_search_for is returning an unblessed reference.

My perl is very shaky, but I am suspicious of these lines in recent_search_for:

    # Finally (or always, if we're logged out), if there's a BUGLIST cookie
    # and the selected bug is in the list, then return the cookie as a fake
    # Search::Recent object.
    if (my $list = $cgi->cookie('BUGLIST')) {
        my @bug_ids = split(':', $list);
        if (grep { $_ == $bug->id } @bug_ids) {
            return { id => 'cookie', bug_list => \@bug_ids };
        }
    }

That return value is a plain hash, rather than an object, isn't it?
(In reply to comment #0)
> That return value is a plain hash, rather than an object, isn't it?

Yes, but that's not the reason of the problem. You can never reach this code from process_bug.cgi, as you must be logged in and the code you mention is for logged out users.
OS: Linux → All
Hardware: x86 → All
Version: unspecified → 3.7.3
Ah - I have also had reports of people being asked to log in multiple times. I wonder if that is related?

I tried to recreate by visiting a bug, deleting my login cookie, then submitting the form, but I was just prompted to log back in instead.
(In reply to comment #1)
> Yes, but that's not the reason of the problem. You can never reach this code
> from process_bug.cgi

I take that back. |return $search if $search| means that's it may not return at that point, and could return the hash you mentioned. I will give it another look.
I've hit this (or something like it) several times.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking4.0+
Target Milestone: --- → Bugzilla 4.0
(In reply to comment #4)
> I've hit this (or something like it) several times.

And you never thought about reporting this issue??? :-p
(In reply to comment #5)
> And you never thought about reporting this issue??? :-p

  No, I did think about reporting it, I just didn't have the time to investigate it or even prove that anybody else was hitting it, when I found it.
For the bug to be triggered, you need to edit a bug that doesn't exist in any of your recent searches, but does exist in the BUGLIST cookie. Here are steps to reproduce:

1. Clear out any entries for your user account in the profile_search table (not 100% necessary, but the error won't occur if the bug you are editing appears in any of your recent searches)

2. Log out, then run a query. This will set the BUGLIST cookie

3. Log back in, and try to edit a bug that *didn't* appear in your last search results.

I don't know the Bugzilla code at all - is it possible to:

a) Return a *real* Search::Recent object that just hasn't been flushed to the database

OR

b) At the end of the "if ($self->id)" block, create a Search::Recent object based on the BUGLIST cookie.
Keywords: qawanted
I can easily reproduce.
Depends on: 578335
Keywords: qawantedregression
Attached patch patch, v1 (obsolete) — Splinter Review
Convert the hash into a real object.
Assignee: create-and-change → LpSolit
Status: NEW → ASSIGNED
Attachment #482044 - Flags: review?(mkanat)
Summary: Occasional "unblessed reference" software error in process_bug.cgi → "Can't call method "bug_list" on unblessed reference" error thrown when editing a bug which is in the BUGLIST cookie but not in a recent saved search, with action="next_bug"
Comment on attachment 482044 [details] [diff] [review]
patch, v1

Ah, this is a good idea, but instead of having this code in Bugzilla::User, we should have a Bugzilla::Search::Recent->cookie method that returns an object with the id of "cookie".
Attachment #482044 - Flags: review?(mkanat) → review-
Attached patch patch, v2Splinter Review
Attachment #482044 - Attachment is obsolete: true
Attachment #483030 - Flags: review?(mkanat)
Comment on attachment 483030 [details] [diff] [review]
patch, v2

Ah, new_from_cookie, great idea! :-)
Attachment #483030 - Flags: review?(mkanat) → review+
Flags: approval4.0+
Flags: approval+
Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/trunk/
modified Bugzilla/User.pm
modified Bugzilla/Search/Recent.pm
Committed revision 7540.

Committing to: bzr+ssh://lpsolit%40gmail.com@bzr.mozilla.org/bugzilla/4.0/
modified Bugzilla/User.pm
modified Bugzilla/Search/Recent.pm
Committed revision 7439.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Thanks a lot for fixing this!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: