[aur-dev] [PATCH 1/2] 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> --- web/lib/pkgfuncs.inc.php | 10 +++++----- 1 file 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; -- 1.7.12
Use "REQUEST_URI" instead of the "PHP_SELF" sever variable to determine the redirection URL for the language selection form. This fixes the language selection feature to work well with virtual URLs. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/template/header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/template/header.php b/web/template/header.php index 2c04b58..d87ddfe 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -29,7 +29,7 @@ <div id="content"> <div id="lang_sub"> - <form method="get" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"], ENT_QUOTES) ?>"> + <form method="get" action="<?php echo htmlspecialchars($_SERVER["REQUEST_URI"], ENT_QUOTES) ?>"> <fieldset> <div> <select name="setlang" id="id_setlang"> -- 1.7.12
participants (1)
-
Lukas Fleischer