Commit c2f00cef authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 314454: Incorrect SQL query in editproducts.cgi when making a group…

Bug 314454: Incorrect SQL query in editproducts.cgi when making a group mandatory - Patch by Elliotte Martin <elliotte_martin@yahoo.com> r/a=LpSolit
parent 54e88736
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# Frédéric Buclin <LpSolit@gmail.com> # Frédéric Buclin <LpSolit@gmail.com>
# Greg Hendricks <ghendricks@novell.com> # Greg Hendricks <ghendricks@novell.com>
# Lance Larsh <lance.larsh@oracle.com> # Lance Larsh <lance.larsh@oracle.com>
# Elliotte Martin <elliotte.martin@yahoo.com>
use strict; use strict;
use lib qw(. lib); use lib qw(. lib);
...@@ -542,20 +543,28 @@ if ($action eq 'updategroupcontrols') { ...@@ -542,20 +543,28 @@ if ($action eq 'updategroupcontrols') {
{'Slice' => {}}, $product->id); {'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; my $mandatory_groups;
if (@now_mandatory) { if (@now_mandatory) {
$mandatory_groups = $dbh->selectall_arrayref( $mandatory_groups = $dbh->selectall_arrayref(
'SELECT groups.name, COUNT(bugs.bug_id) AS count 'SELECT groups.name,
(SELECT COUNT(bugs.bug_id)
FROM bugs FROM bugs
LEFT JOIN bug_group_map WHERE bugs.product_id = ?
ON bug_group_map.bug_id = bugs.bug_id AND bugs.bug_id NOT IN
INNER JOIN groups (SELECT bug_group_map.bug_id FROM bug_group_map
ON bug_group_map.group_id = groups.id WHERE bug_group_map.group_id = groups.id))
AS count
FROM groups
WHERE groups.id IN (' . join(', ', @now_mandatory) . ') WHERE groups.id IN (' . join(', ', @now_mandatory) . ')
AND bugs.product_id = ? ORDER BY groups.name',
AND bug_group_map.bug_id IS NULL ' .
$dbh->sql_group_by('groups.name'),
{'Slice' => {}}, $product->id); {'Slice' => {}}, $product->id);
# remove zero counts
@$mandatory_groups = grep { $_->{count} } @$mandatory_groups;
} }
if (($na_groups && scalar(@$na_groups)) if (($na_groups && scalar(@$na_groups))
|| ($mandatory_groups && scalar(@$mandatory_groups))) || ($mandatory_groups && scalar(@$mandatory_groups)))
......
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