summaryrefslogtreecommitdiffstats
path: root/editproducts.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2008-04-12 06:39:45 +0200
committerlpsolit%gmail.com <>2008-04-12 06:39:45 +0200
commitc2f00cef7a67836ef27274ca62994f67a1ebc362 (patch)
tree5f2d0b8be46dd8b75ea0d9a398cfc2bd3db12228 /editproducts.cgi
parent54e88736acd23b4b1cf4c8c7794e8ee5309e836a (diff)
downloadbugzilla-c2f00cef7a67836ef27274ca62994f67a1ebc362.tar.gz
bugzilla-c2f00cef7a67836ef27274ca62994f67a1ebc362.tar.xz
Bug 314454: Incorrect SQL query in editproducts.cgi when making a group mandatory - Patch by Elliotte Martin <elliotte_martin@yahoo.com> r/a=LpSolit
Diffstat (limited to 'editproducts.cgi')
-rwxr-xr-xeditproducts.cgi29
1 files changed, 19 insertions, 10 deletions
diff --git a/editproducts.cgi b/editproducts.cgi
index 4347ce836..c7e7fe13c 100755
--- a/editproducts.cgi
+++ b/editproducts.cgi
@@ -26,6 +26,7 @@
# Frédéric Buclin <LpSolit@gmail.com>
# Greg Hendricks <ghendricks@novell.com>
# Lance Larsh <lance.larsh@oracle.com>
+# Elliotte Martin <elliotte.martin@yahoo.com>
use strict;
use lib qw(. lib);
@@ -542,20 +543,28 @@ if ($action eq 'updategroupcontrols') {
{'Slice' => {}}, $product->id);
}
+#
+# return the mandatory groups which need to have bug entries added to the bug_group_map
+# and the corresponding bug count
+#
my $mandatory_groups;
if (@now_mandatory) {
$mandatory_groups = $dbh->selectall_arrayref(
- 'SELECT groups.name, COUNT(bugs.bug_id) AS count
- FROM bugs
- LEFT JOIN bug_group_map
- ON bug_group_map.bug_id = bugs.bug_id
- INNER JOIN groups
- ON bug_group_map.group_id = groups.id
- WHERE groups.id IN (' . join(', ', @now_mandatory) . ')
- AND bugs.product_id = ?
- AND bug_group_map.bug_id IS NULL ' .
- $dbh->sql_group_by('groups.name'),
+ 'SELECT groups.name,
+ (SELECT COUNT(bugs.bug_id)
+ FROM bugs
+ WHERE bugs.product_id = ?
+ AND bugs.bug_id NOT IN
+ (SELECT bug_group_map.bug_id FROM bug_group_map
+ WHERE bug_group_map.group_id = groups.id))
+ AS count
+ FROM groups
+ WHERE groups.id IN (' . join(', ', @now_mandatory) . ')
+ ORDER BY groups.name',
{'Slice' => {}}, $product->id);
+ # remove zero counts
+ @$mandatory_groups = grep { $_->{count} } @$mandatory_groups;
+
}
if (($na_groups && scalar(@$na_groups))
|| ($mandatory_groups && scalar(@$mandatory_groups)))