Commit 9d202f2d authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 289043: Implicit joins should be replaced by explicit joins - installment C

Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=joel, a=justdave
parent 95859bf1
...@@ -336,14 +336,14 @@ if (!$action && !$product) { ...@@ -336,14 +336,14 @@ if (!$action && !$product) {
FROM products"; FROM products";
if (Param('useclassification')) { if (Param('useclassification')) {
$query .= ", classifications"; $query .= " INNER JOIN classifications " .
"ON classifications.id = products.classification_id";
} }
$query .= " LEFT JOIN bugs ON products.id = bugs.product_id"; $query .= " LEFT JOIN bugs ON products.id = bugs.product_id";
if (Param('useclassification')) { if (Param('useclassification')) {
$query .= " WHERE classifications.name = ? " . $query .= " WHERE classifications.name = ? ";
" AND classifications.id = products.classification_id";
# trick_taint is OK because we use this in a placeholder in a SELECT # trick_taint is OK because we use this in a placeholder in a SELECT
trick_taint($classification); trick_taint($classification);
...@@ -1038,14 +1038,15 @@ if ($action eq 'updategroupcontrols') { ...@@ -1038,14 +1038,15 @@ if ($action eq 'updategroupcontrols') {
my @mandatory_groups = (); my @mandatory_groups = ();
if (@now_mandatory) { if (@now_mandatory) {
SendSQL("SELECT groups.name, COUNT(bugs.bug_id) SendSQL("SELECT groups.name, COUNT(bugs.bug_id)
FROM bugs, groups FROM bugs
LEFT JOIN bug_group_map LEFT JOIN bug_group_map
ON bug_group_map.group_id = groups.id ON bug_group_map.bug_id = bugs.bug_id
AND bug_group_map.bug_id = bugs.bug_id INNER JOIN groups
WHERE groups.id IN(" . join(', ', @now_mandatory) . ") ON bug_group_map.group_id = groups.id
AND bugs.product_id = $product_id WHERE groups.id IN(" . join(', ', @now_mandatory) . ")
AND bug_group_map.bug_id IS NULL " . AND bugs.product_id = $product_id
$dbh->sql_group_by('groups.name')); AND bug_group_map.bug_id IS NULL " .
$dbh->sql_group_by('groups.name'));
while (MoreSQLData()) { while (MoreSQLData()) {
my ($groupname, $bugcount) = FetchSQLData(); my ($groupname, $bugcount) = FetchSQLData();
my %g = (); my %g = ();
......
...@@ -622,13 +622,14 @@ sub groupsUserMayBless { ...@@ -622,13 +622,14 @@ sub groupsUserMayBless {
$connector = 'WHERE'; $connector = 'WHERE';
} else { } else {
$query = qq{SELECT DISTINCT $fieldList $query = qq{SELECT DISTINCT $fieldList
FROM groups, user_group_map AS ugm FROM groups
LEFT JOIN user_group_map AS ugm
ON groups.id = ugm.group_id
LEFT JOIN group_group_map AS ggm LEFT JOIN group_group_map AS ggm
ON ggm.member_id = ugm.group_id ON ggm.member_id = ugm.group_id
AND ggm.grant_type = ? AND ggm.grant_type = ?
WHERE user_id = ? WHERE user_id = ?
AND ((id = group_id AND isbless = 1) OR AND (ugm.isbless = 1 OR groups.id = ggm.grantor_id)
(id = grantor_id))
}; };
@bindValues = (GROUP_BLESS, $userid); @bindValues = (GROUP_BLESS, $userid);
$connector = 'AND'; $connector = 'AND';
......
...@@ -171,13 +171,14 @@ sub GenerateVersionTable { ...@@ -171,13 +171,14 @@ sub GenerateVersionTable {
my $mpart = $dotargetmilestone ? ", milestoneurl" : ""; my $mpart = $dotargetmilestone ? ", milestoneurl" : "";
SendSQL("select name, description from classifications ORDER BY name"); SendSQL("SELECT name, description FROM classifications ORDER BY name");
while (@line = FetchSQLData()) { while (@line = FetchSQLData()) {
my ($n, $d) = (@line); my ($n, $d) = (@line);
$::classdesc{$n} = $d; $::classdesc{$n} = $d;
} }
SendSQL("select name, description, votesperuser, disallownew$mpart from products ORDER BY name"); SendSQL("SELECT name, description, votesperuser, disallownew$mpart " .
"FROM products ORDER BY name");
while (@line = FetchSQLData()) { while (@line = FetchSQLData()) {
my ($p, $d, $votesperuser, $dis, $u) = (@line); my ($p, $d, $votesperuser, $dis, $u) = (@line);
$::proddesc{$p} = $d; $::proddesc{$p} = $d;
...@@ -604,7 +605,7 @@ sub DBID_to_name { ...@@ -604,7 +605,7 @@ sub DBID_to_name {
} }
if (!defined $::cachedNameArray{$id}) { if (!defined $::cachedNameArray{$id}) {
PushGlobalSQLState(); PushGlobalSQLState();
SendSQL("select login_name from profiles where userid = $id"); SendSQL("SELECT login_name FROM profiles WHERE userid = $id");
my $r = FetchOneColumn(); my $r = FetchOneColumn();
PopGlobalSQLState(); PopGlobalSQLState();
if (!defined $r || $r eq "") { if (!defined $r || $r eq "") {
......
...@@ -288,7 +288,7 @@ if (UserInGroup("editbugs") && defined($cgi->param('dependson'))) { ...@@ -288,7 +288,7 @@ if (UserInGroup("editbugs") && defined($cgi->param('dependson'))) {
my @stack = @{$deps{$target}}; my @stack = @{$deps{$target}};
while (@stack) { while (@stack) {
my $i = shift @stack; my $i = shift @stack;
SendSQL("select $target from dependencies where $me = " . SendSQL("SELECT $target FROM dependencies WHERE $me = " .
SqlQuote($i)); SqlQuote($i));
while (MoreSQLData()) { while (MoreSQLData()) {
my $t = FetchOneColumn(); my $t = FetchOneColumn();
...@@ -439,7 +439,7 @@ if (Param("insidergroup") && UserInGroup(Param("insidergroup"))) { ...@@ -439,7 +439,7 @@ if (Param("insidergroup") && UserInGroup(Param("insidergroup"))) {
} }
SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext, isprivate) SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext, isprivate)
VALUES ($id, " . SqlQuote($user->id) . ", $sql_timestamp, " . VALUES ($id, " . SqlQuote($user->id) . ", $sql_timestamp, " .
SqlQuote($comment) . ", $privacy)"); SqlQuote($comment) . ", $privacy)");
# Insert the cclist into the database # Insert the cclist into the database
......
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