Squelch warning in pkgbase_vote()

Do not trigger a PHP warning if there are no votes to be added or
removed.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2017-02-27 20:09:15 +01:00
parent 92f140c5ca
commit 06cf067d4f

View file

@ -735,6 +735,8 @@ function pkgbase_vote ($base_ids, $action=true) {
$uid = uid_from_sid($_COOKIE["AURSID"]); $uid = uid_from_sid($_COOKIE["AURSID"]);
$first = 1; $first = 1;
$vote_ids = "";
$vote_clauses = "";
foreach ($base_ids as $pid) { foreach ($base_ids as $pid) {
if ($action) { if ($action) {
$check = !isset($my_votes[$pid]); $check = !isset($my_votes[$pid]);
@ -758,6 +760,7 @@ function pkgbase_vote ($base_ids, $action=true) {
} }
} }
if (!empty($vote_ids)) {
/* Only add votes for packages the user hasn't already voted for. */ /* Only add votes for packages the user hasn't already voted for. */
$op = $action ? "+" : "-"; $op = $action ? "+" : "-";
$q = "UPDATE PackageBases SET NumVotes = NumVotes $op 1 "; $q = "UPDATE PackageBases SET NumVotes = NumVotes $op 1 ";
@ -774,6 +777,7 @@ function pkgbase_vote ($base_ids, $action=true) {
} }
$dbh->exec($q); $dbh->exec($q);
}
if ($action) { if ($action) {
return array(true, __("Your votes have been cast for the selected packages.")); return array(true, __("Your votes have been cast for the selected packages."));