Commit 431731b1 authored by travis%sedsystems.ca's avatar travis%sedsystems.ca

Bug 279544: Bug.pm: Eliminate deprecated Bugzilla::DB routines

Patch by Max Kanat-Alexander <mkanat@kerio.com> r=wurblzap a=justdave
parent 4046c8b3
...@@ -35,6 +35,7 @@ use vars qw($unconfirmedstate $legal_keywords @legal_platform ...@@ -35,6 +35,7 @@ use vars qw($unconfirmedstate $legal_keywords @legal_platform
use CGI::Carp qw(fatalsToBrowser); use CGI::Carp qw(fatalsToBrowser);
use Bugzilla;
use Bugzilla::Attachment; use Bugzilla::Attachment;
use Bugzilla::Config; use Bugzilla::Config;
use Bugzilla::Constants; use Bugzilla::Constants;
...@@ -109,6 +110,7 @@ sub new { ...@@ -109,6 +110,7 @@ sub new {
sub initBug { sub initBug {
my $self = shift(); my $self = shift();
my ($bug_id, $user_id) = (@_); my ($bug_id, $user_id) = (@_);
my $dbh = Bugzilla->dbh;
$bug_id = trim($bug_id); $bug_id = trim($bug_id);
...@@ -150,16 +152,18 @@ sub initBug { ...@@ -150,16 +152,18 @@ sub initBug {
estimated_time, remaining_time, DATE_FORMAT(deadline,'%Y-%m-%d') estimated_time, remaining_time, DATE_FORMAT(deadline,'%Y-%m-%d')
from bugs left join votes using(bug_id), from bugs left join votes using(bug_id),
classifications, products, components classifications, products, components
where bugs.bug_id = $bug_id WHERE bugs.bug_id = ?
AND classifications.id = products.classification_id AND classifications.id = products.classification_id
AND products.id = bugs.product_id AND products.id = bugs.product_id
AND components.id = bugs.component_id AND components.id = bugs.component_id
group by bugs.bug_id"; group by bugs.bug_id";
&::SendSQL($query); my $bug_sth = $dbh->prepare($query);
my @row = (); $bug_sth->execute($bug_id);
my @row;
if ((@row = &::FetchSQLData()) && $self->{'who'}->can_see_bug($bug_id)) { if ((@row = $bug_sth->fetchrow_array())
&& $self->{'who'}->can_see_bug($bug_id)) {
my $count = 0; my $count = 0;
my %fields; my %fields;
foreach my $field ("bug_id", "alias", "classification_id", "classification", foreach my $field ("bug_id", "alias", "classification_id", "classification",
...@@ -205,17 +209,16 @@ sub initBug { ...@@ -205,17 +209,16 @@ sub initBug {
} }
if (@::legal_keywords) { if (@::legal_keywords) {
&::SendSQL("SELECT keyworddefs.name # Get all entries and make them an array.
my $list_ref = $dbh->selectcol_arrayref(
"SELECT keyworddefs.name
FROM keyworddefs, keywords FROM keyworddefs, keywords
WHERE keywords.bug_id = $bug_id WHERE keywords.bug_id = ?
AND keyworddefs.id = keywords.keywordid AND keyworddefs.id = keywords.keywordid
ORDER BY keyworddefs.name"); ORDER BY keyworddefs.name",
my @list; undef, ($bug_id));
while (&::MoreSQLData()) { if ($list_ref) {
push(@list, &::FetchOneColumn()); $self->{'keywords'} = join(', ', @$list_ref);
}
if (@list) {
$self->{'keywords'} = join(', ', @list);
} }
} }
...@@ -329,6 +332,7 @@ sub groups { ...@@ -329,6 +332,7 @@ sub groups {
return $self->{'groups'} if exists $self->{'groups'}; return $self->{'groups'} if exists $self->{'groups'};
my $dbh = Bugzilla->dbh;
my @groups; my @groups;
# Some of this stuff needs to go into Bugzilla::User # Some of this stuff needs to go into Bugzilla::User
...@@ -338,26 +342,28 @@ sub groups { ...@@ -338,26 +342,28 @@ sub groups {
# user_group_map record putting the user in that group. # user_group_map record putting the user in that group.
# The LEFT JOINs are checking for record existence. # The LEFT JOINs are checking for record existence.
# #
&::SendSQL("SELECT DISTINCT groups.id, name, description," . my $sth = $dbh->prepare(
"SELECT DISTINCT groups.id, name, description," .
" bug_group_map.group_id IS NOT NULL," . " bug_group_map.group_id IS NOT NULL," .
" user_group_map.group_id IS NOT NULL," . " user_group_map.group_id IS NOT NULL," .
" isactive, membercontrol, othercontrol" . " isactive, membercontrol, othercontrol" .
" FROM groups" . " FROM groups" .
" LEFT JOIN bug_group_map" . " LEFT JOIN bug_group_map" .
" ON bug_group_map.group_id = groups.id" . " ON bug_group_map.group_id = groups.id" .
" AND bug_id = $self->{'bug_id'}" . " AND bug_id = ?" .
" LEFT JOIN user_group_map" . " LEFT JOIN user_group_map" .
" ON user_group_map.group_id = groups.id" . " ON user_group_map.group_id = groups.id" .
" AND user_id = $::userid" . " AND user_id = ?" .
" AND isbless = 0" . " AND isbless = 0" .
" LEFT JOIN group_control_map" . " LEFT JOIN group_control_map" .
" ON group_control_map.group_id = groups.id" . " ON group_control_map.group_id = groups.id" .
" AND group_control_map.product_id = " . $self->{'product_id'} . " AND group_control_map.product_id = ? " .
" WHERE isbuggroup = 1"); " WHERE isbuggroup = 1");
$sth->execute($self->{'bug_id'}, Bugzilla->user->id,
$self->{'product_id'});
while (&::MoreSQLData()) { while (my ($groupid, $name, $description, $ison, $ingroup, $isactive,
my ($groupid, $name, $description, $ison, $ingroup, $isactive, $membercontrol, $othercontrol) = $sth->fetchrow_array()) {
$membercontrol, $othercontrol) = &::FetchSQLData();
$membercontrol ||= 0; $membercontrol ||= 0;
...@@ -392,8 +398,6 @@ sub user { ...@@ -392,8 +398,6 @@ sub user {
my $self = shift; my $self = shift;
return $self->{'user'} if exists $self->{'user'}; return $self->{'user'} if exists $self->{'user'};
use Bugzilla;
my @movers = map { trim $_ } split(",", Param("movers")); my @movers = map { trim $_ } split(",", Param("movers"));
my $canmove = Param("move-enabled") && Bugzilla->user->id && my $canmove = Param("move-enabled") && Bugzilla->user->id &&
(lsearch(\@movers, Bugzilla->user->login) != -1); (lsearch(\@movers, Bugzilla->user->login) != -1);
...@@ -483,18 +487,17 @@ sub choices { ...@@ -483,18 +487,17 @@ sub choices {
} }
sub EmitDependList { sub EmitDependList {
my ($myfield, $targetfield, $bug_id) = (@_); my ($myfield, $targetfield, $bug_id) = (@_);
my @list; my $dbh = Bugzilla->dbh;
&::SendSQL("select dependencies.$targetfield, bugs.bug_status my $list_ref =
from dependencies, bugs $dbh->selectcol_arrayref(
where dependencies.$myfield = $bug_id "SELECT dependencies.$targetfield
and bugs.bug_id = dependencies.$targetfield FROM dependencies, bugs
order by dependencies.$targetfield"); WHERE dependencies.$myfield = ?
while (&::MoreSQLData()) { AND bugs.bug_id = dependencies.$targetfield
my ($i, $stat) = (&::FetchSQLData()); ORDER BY dependencies.$targetfield",
push @list, $i; undef, ($bug_id));
} return @$list_ref;
return @list;
} }
sub ValidateTime { sub ValidateTime {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment