Commit 1a40b1fe authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 364284: User::get_selectable_products() can return wrong data if…

Bug 364284: User::get_selectable_products() can return wrong data if $classification_id is passed - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=bkor a=justdave
parent 504a510d
...@@ -628,39 +628,32 @@ sub can_see_product { ...@@ -628,39 +628,32 @@ sub can_see_product {
sub get_selectable_products { sub get_selectable_products {
my $self = shift; my $self = shift;
my $classification_id = shift; my $class_id = shift;
my $class_restricted = Bugzilla->params->{'useclassification'} && $class_id;
if (defined $self->{selectable_products}) {
return $self->{selectable_products};
}
my $dbh = Bugzilla->dbh;
my @params = ();
if (!defined $self->{selectable_products}) {
my $query = "SELECT id " . my $query = "SELECT id " .
"FROM products " . " FROM products " .
"LEFT JOIN group_control_map " . "LEFT JOIN group_control_map " .
"ON group_control_map.product_id = products.id "; " ON group_control_map.product_id = products.id ";
if (Bugzilla->params->{'useentrygroupdefault'}) { if (Bugzilla->params->{'useentrygroupdefault'}) {
$query .= "AND group_control_map.entry != 0 "; $query .= " AND group_control_map.entry != 0 ";
} else { } else {
$query .= "AND group_control_map.membercontrol = " . $query .= " AND group_control_map.membercontrol = " . CONTROLMAPMANDATORY;
CONTROLMAPMANDATORY . " ";
} }
$query .= "AND group_id NOT IN(" . $query .= " AND group_id NOT IN(" . $self->groups_as_string . ") " .
$self->groups_as_string . ") " . " WHERE group_id IS NULL " .
"WHERE group_id IS NULL "; "ORDER BY name";
if (Bugzilla->params->{'useclassification'} && $classification_id) { my $prod_ids = Bugzilla->dbh->selectcol_arrayref($query);
$query .= "AND classification_id = ? "; $self->{selectable_products} = Bugzilla::Product->new_from_list($prod_ids);
detaint_natural($classification_id);
push(@params, $classification_id);
} }
$query .= "ORDER BY name"; # Restrict the list of products to those being in the classification, if any.
if ($class_restricted) {
my $prod_ids = $dbh->selectcol_arrayref($query, undef, @params); return [grep {$_->classification_id == $class_id} @{$self->{selectable_products}}];
$self->{selectable_products} = Bugzilla::Product->new_from_list($prod_ids); }
# If we come here, then we want all selectable products.
return $self->{selectable_products}; return $self->{selectable_products};
} }
......
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