mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fix package notification
One cannot check if the PDOStatement object returned by query()
evaluates to true in order to check for a non-empty record set. Modify
the SQL query to count the number of records instead of retrieving the
records themselves and fixing the check.
Regression introduced in e171f6f34e
.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
f37f0eaea1
commit
96c36dc84f
1 changed files with 5 additions and 5 deletions
|
@ -1134,12 +1134,12 @@ function pkg_notify ($atype, $ids, $action=true, $dbh=NULL) {
|
||||||
|
|
||||||
|
|
||||||
if ($action) {
|
if ($action) {
|
||||||
$q = "SELECT * FROM CommentNotify WHERE UserID = $uid";
|
$q = "SELECT COUNT(*) FROM CommentNotify WHERE ";
|
||||||
$q .= " AND PkgID = $pid";
|
$q .= "UserID = $uid AND PkgID = $pid";
|
||||||
|
|
||||||
# Notification already added. Don't add again.
|
# Notification already added. Don't add again.
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
if (!$result) {
|
if ($result->fetchColumn() == 0) {
|
||||||
$q = "INSERT INTO CommentNotify (PkgID, UserID) VALUES ($pid, $uid)";
|
$q = "INSERT INTO CommentNotify (PkgID, UserID) VALUES ($pid, $uid)";
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
}
|
}
|
||||||
|
@ -1147,8 +1147,8 @@ function pkg_notify ($atype, $ids, $action=true, $dbh=NULL) {
|
||||||
$output .= $pkgname;
|
$output .= $pkgname;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$q = "DELETE FROM CommentNotify WHERE PkgID = $pid";
|
$q = "DELETE FROM CommentNotify WHERE PkgID = $pid ";
|
||||||
$q .= " AND UserID = $uid";
|
$q .= "AND UserID = $uid";
|
||||||
$dbh->exec($q);
|
$dbh->exec($q);
|
||||||
|
|
||||||
$output .= $pkgname;
|
$output .= $pkgname;
|
||||||
|
|
Loading…
Add table
Reference in a new issue