Closed Bug 226477 Opened 22 years ago Closed 21 years ago

Bugzilla::User->in_group calls non-existent method $dbh->selectrow

Categories

(Bugzilla :: User Accounts, defect, P3)

2.17.6
x86
Linux
defect

Tracking

()

RESOLVED FIXED
Bugzilla 2.18

People

(Reporter: jgreen, Assigned: bugreport)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 The Bugzilla::User->in_group method (Bugzilla/User.pm) calls $dbh->selectrow, which is not a DBI method. Changing the call to $dbh->selectrow_array fixes the problem. Reproducible: Always Steps to Reproduce: I call this method directly from a script for importing bugs from another bug system, so I'm not sure how to reproduce this with the standard distribution. Still, I think the problem can be seen by simple inspection. Actual Results: When the method is call, it fails with an error saying that DBI::db cannot identify the method "selectrow". Expected Results: The Bugzilla method should not have crashed.
This is the patch I use to fix this problem.
This happens in the 2.17.6 version of Bugzilla.
Version: unspecified → 2.17.6
I can't reproduce the error (I've been using $user->in_group() in some of my stuff and it hasn't errored - then again, I'm calling $user->groups() earlier, which caches them. The DBI docs agree though.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 136068 [details] [diff] [review] Patch to fix invalid $dbh-selectrow call in Bugzilla::User->in_group actually this was a little more broken than that... because it returns an array, we need to qualify $res as an array element to receive the response. my ($res) = $dbh->.....
Attachment #136068 - Flags: review-
> actually this was a little more broken than that... because it returns an > array, we need to qualify $res as an array element to receive the response. In this case it may be OK without the array qualifier, since all that is wanted is a present/not present result, assuming that no match returns a zero-length array. If it's not OK, there are 3 or 4 other occurrences of the same structure in Bugzilla/User.pm.
selectrow is an alias for selectrow_array, which in scalar context returns either teh first or the last coulmn in the query. (its undefined which). As long as the query only selects one column, its fine.
> selectrow is an alias for selectrow_array, which in scalar context returns > either teh first or the last coulmn in the query. (its undefined which). Can you give me a pointer to where the support for this is? It failed on my system as an unknown method, and I just downloaded DBI-1.38 from dbi.perl.org, and I don't see it in there either.
Hmm. I thought it was, but its fetch that is the alias for fetchrow_array, and theres no equiv alias for select. Bleh. How did this ever work?
To both see the problem and test the fix, you can slide this code into a copy of index.cgi my $joel = Bugzilla::User->new(1); print "content-type: text/plain\n\n"; print $joel->in_group("admin"); exit;
Attachment #136068 - Attachment is obsolete: true
Attachment #148252 - Flags: review?
Attachment #148252 - Flags: review? → review+
Assignee: myk → bugreport
Flags: approval?
Priority: -- → P3
Target Milestone: --- → Bugzilla 2.18
Flags: approval? → approval+
Checking in Bugzilla/User.pm; /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v <-- User.pm new revision: 1.18; previous revision: 1.17 done Nice catch, Joe
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: