"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"

RESOLVED FIXED in Bugzilla 4.0

Status

()

Bugzilla
Creating/Changing Bugs
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: Simon King, Assigned: Frédéric Buclin)

Tracking

({regression})

3.7.3
Bugzilla 4.0
regression
Bug Flags:
approval +
approval4.0 +
blocking4.0 +

Details

Attachments

(1 attachment, 1 obsolete attachment)

1.43 KB, patch
Max Kanat-Alexander
: review+
Details | Diff | Splinter Review
(Reporter)

Description

7 years ago
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?
(Assignee)

Comment 1

7 years ago
(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
(Reporter)

Comment 2

7 years ago
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.
(Assignee)

Comment 3

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

Comment 4

7 years ago
I've hit this (or something like it) several times.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking4.0+
Target Milestone: --- → Bugzilla 4.0
(Assignee)

Comment 5

7 years ago
(In reply to comment #4)
> I've hit this (or something like it) several times.

And you never thought about reporting this issue??? :-p

Comment 6

7 years ago
(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.
(Reporter)

Comment 7

7 years ago
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.
(Assignee)

Updated

7 years ago
Keywords: qawanted
(Assignee)

Comment 8

7 years ago
I can easily reproduce.
Depends on: 578335
Keywords: qawanted → regression
(Assignee)

Comment 9

7 years ago
Created attachment 482044 [details] [diff] [review]
patch, v1

Convert the hash into a real object.
Assignee: create-and-change → LpSolit
Status: NEW → ASSIGNED
Attachment #482044 - Flags: review?(mkanat)
(Assignee)

Updated

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

7 years ago
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-
(Assignee)

Comment 11

7 years ago
Created attachment 483030 [details] [diff] [review]
patch, v2
Attachment #482044 - Attachment is obsolete: true
Attachment #483030 - Flags: review?(mkanat)

Comment 12

7 years ago
Comment on attachment 483030 [details] [diff] [review]
patch, v2

Ah, new_from_cookie, great idea! :-)
Attachment #483030 - Flags: review?(mkanat) → review+

Updated

7 years ago
Flags: approval4.0+
Flags: approval+
(Assignee)

Comment 13

7 years ago
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
Last Resolved: 7 years ago
Resolution: --- → FIXED
(Reporter)

Comment 14

7 years ago
Thanks a lot for fixing this!
You need to log in before you can comment on or make changes to this bug.