[aur-dev] [PATCH 1/2] Merge user ids in CommentNotify

Marcel Korpel marcel.korpel at gmail.com
Wed Jun 17 00:08:19 UTC 2015


Fixes FS#27687.

Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
---
 web/lib/pkgbasefuncs.inc.php | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index c8c99eb..e255cb4 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -508,6 +508,24 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via, $grant=false) {
 		$q.= "WHERE PackageBaseID IN (" . implode(",", $base_ids) . ")";
 		$dbh->exec($q);
 
+		/* Merge comment notifications */
+		$q = "SELECT UserID FROM CommentNotify ";
+		$q.= "WHERE PackageBaseID IN (" . implode(",", $base_ids) . ")";
+		$result = $dbh->query($q);
+
+		while ($uid = $result->fetchColumn(0)) {
+			/* Check if a user already gets notifications from $merge_base_id */
+			$q = "SELECT COUNT(*) FROM CommentNotify WHERE ";
+			$q .= "UserID = $uid AND PackageBaseID = " . intval($merge_base_id);
+
+			$result_notif = $dbh->query($q);
+			if ($result_notif->fetchColumn() == 0) {
+				$q = "INSERT INTO CommentNotify (PackageBaseID, UserID) VALUES (";
+				$q.= intval($merge_base_id) . ", $uid)";
+				$dbh->exec($q);
+			}
+		}
+
 		/* Merge votes */
 		foreach ($base_ids as $base_id) {
 			$q = "UPDATE PackageVotes ";
-- 
2.4.3


More information about the aur-dev mailing list