Hello, guest. We have noticed that you are not registered at this bug tracker. Your experience will be greatly enhanced if you log in. To do so, you first must register by clicking on the Register tab at the top. If you are already registered, you can login at the Login tab.
Syndicate Syndicate Listing Display Search Login/Register
Bug Id ?
202
Reporter ?
dtmackenzie
Bugdar / 1.2.3
Status ?
Unconfirmed
Severity ?
Minor
Duplicate Of ?
- none -
Fixed in Revision ?
Mstone ?
Summary ?
Search for product/component/version shows all combinations of selected values rather than the combinations selected.
Report Time ?
July 1, 2010 08:09 AM
Assignment ?
Resolution ?
Open
Priority ?
Normal
Dependencies ?
- none -
Mstone (old) ?


Votes
For: 0 (0%)
Against: 0 (0%)
Total: 0

July 1, 2010 08:09 AM dtmackenzie
For example, if product A, component X, version 1 (=AX1) and similarly BY2 selected, then the results also include those for AX2, AY1, BX1... etc.

The code line to be fixed is the following in search.php -
$querybuild['pcv'] = "AND bug.product IN (" . implode(',', $products) . ") AND bug.component IN (" . implode(',', $components) . ") AND bug.version IN (" . implode(',', $versions) . ")";
The problem is that the three IN conditions are independent from each other - elegant but incorrect.

Unfortunately it is necessary to generate each condition explicitly, e.g. as follows -
$qb = "AND (";
foreach ($products AS $pkey => $pvalue)
{
if ($pkey > 0)
{
$qb .= " OR ";
}
$qb .= "(bug.product=" . $pvalue;
if ($components[$pkey] != 0)
{
$qb .= " AND bug.component=" . $components[$pkey];
}
$qb .= " AND bug.version=" . $versions[$pkey] . ")";
}
$querybuild['pcv'] = $qb . ")";

The "if ($components[$pkey] != 0)" omits the component check for the product itself, i.e. if the main product rather than a component is selected then all results for components of that product are included - this may be a matter of taste, but we prefer it that way.