]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 440259 (2nd attempt): User::match should be using Bugzilla::User->new_from_list...
authorlpsolit%gmail.com <>
Thu, 9 Apr 2009 13:45:18 +0000 (13:45 +0000)
committerlpsolit%gmail.com <>
Thu, 9 Apr 2009 13:45:18 +0000 (13:45 +0000)
Bugzilla/User.pm

index b6754c472b9f4f1a002c471ee33988944b3ea912..2a616a145f604bbd42c5b909eeb262a41160ac89 100644 (file)
@@ -1017,7 +1017,7 @@ sub match {
     if ($wildstr =~ s/\*/\%/g) { # don't do wildcards if no '*' in the string
         # Build the query.
         trick_taint($wildstr);
-        my $query  = "SELECT DISTINCT login_name FROM profiles ";
+        my $query  = "SELECT DISTINCT userid FROM profiles ";
         if (Bugzilla->params->{'usevisibilitygroups'}) {
             $query .= "INNER JOIN user_group_map
                                ON user_group_map.user_id = profiles.userid ";
@@ -1031,15 +1031,12 @@ sub match {
                       join(', ', (-1, @{$user->visible_groups_inherited})) . ") ";
         }
         $query    .= " AND disabledtext = '' " if $exclude_disabled;
-        $query    .= " ORDER BY login_name ";
         $query    .= $dbh->sql_limit($limit) if $limit;
 
         # Execute the query, retrieve the results, and make them into
         # User objects.
-        my $user_logins = $dbh->selectcol_arrayref($query, undef, ($wildstr, $wildstr));
-        foreach my $login_name (@$user_logins) {
-            push(@users, new Bugzilla::User({ name => $login_name }));
-        }
+        my $user_ids = $dbh->selectcol_arrayref($query, undef, ($wildstr, $wildstr));
+        @users = @{Bugzilla::User->new_from_list($user_ids)};
     }
     else {    # try an exact match
         # Exact matches don't care if a user is disabled.
@@ -1055,7 +1052,7 @@ sub match {
     if (!scalar(@users) && length($str) >= 3) {
         trick_taint($str);
 
-        my $query   = "SELECT DISTINCT login_name FROM profiles ";
+        my $query   = "SELECT DISTINCT userid FROM profiles ";
         if (Bugzilla->params->{'usevisibilitygroups'}) {
             $query .= "INNER JOIN user_group_map
                                ON user_group_map.user_id = profiles.userid ";
@@ -1069,13 +1066,9 @@ sub match {
                 join(', ', (-1, @{$user->visible_groups_inherited})) . ") ";
         }
         $query     .= " AND disabledtext = '' " if $exclude_disabled;
-        $query    .= " ORDER BY login_name ";
         $query     .= $dbh->sql_limit($limit) if $limit;
-
-        my $user_logins = $dbh->selectcol_arrayref($query, undef, ($str, $str));
-        foreach my $login_name (@$user_logins) {
-            push(@users, new Bugzilla::User({ name => $login_name }));
-        }
+        my $user_ids = $dbh->selectcol_arrayref($query, undef, ($str, $str));
+        @users = @{Bugzilla::User->new_from_list($user_ids)};
     }
     return \@users;
 }