summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2012-09-18 15:02:58 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-09-18 15:14:34 +0200
commit96c36dc84f2dbce42e3af6453b7df916d07f0a39 (patch)
tree3c9daf083222f404b10553e6122fe5e7b69666bd /web/lib/pkgfuncs.inc.php
parentf37f0eaea1b276614856b300cd7c51eb27c7d138 (diff)
downloadaurweb-96c36dc84f2dbce42e3af6453b7df916d07f0a39.tar.xz
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 e171f6f34eeacf35cf7142b4788d43e7d0978546. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 0b3a6cb..593ccde 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -1134,12 +1134,12 @@ function pkg_notify ($atype, $ids, $action=true, $dbh=NULL) {
if ($action) {
- $q = "SELECT * FROM CommentNotify WHERE UserID = $uid";
- $q .= " AND PkgID = $pid";
+ $q = "SELECT COUNT(*) FROM CommentNotify WHERE ";
+ $q .= "UserID = $uid AND PkgID = $pid";
# Notification already added. Don't add again.
$result = $dbh->query($q);
- if (!$result) {
+ if ($result->fetchColumn() == 0) {
$q = "INSERT INTO CommentNotify (PkgID, UserID) VALUES ($pid, $uid)";
$dbh->exec($q);
}
@@ -1147,8 +1147,8 @@ function pkg_notify ($atype, $ids, $action=true, $dbh=NULL) {
$output .= $pkgname;
}
else {
- $q = "DELETE FROM CommentNotify WHERE PkgID = $pid";
- $q .= " AND UserID = $uid";
+ $q = "DELETE FROM CommentNotify WHERE PkgID = $pid ";
+ $q .= "AND UserID = $uid";
$dbh->exec($q);
$output .= $pkgname;