Skip to content

Commit

Permalink
#5023 Add impossible clause for no values listed
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Sep 13, 2019
1 parent 6ca1c06 commit e690d3e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion classes/statistics/PKPMetricsDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ function &getMetrics($metricType, $columns = array(), $filters = array(), $order
if (is_scalar($values)) {
$currentClause .= "$column = ?";
$params[] = $values;
} else {
} elseif (count($values)) {
$placeholders = array_pad(array(), count($values), '?');
$placeholders = implode(', ', $placeholders);
$currentClause .= "$column IN ($placeholders)";
foreach ($values as $value) {
$params[] = $value;
}
} else {
// count($values) == 0: No matches should be returned.
$currentClause .= '1=0';
}
}

Expand Down

0 comments on commit e690d3e

Please sign in to comment.