[aur-dev] [PATCH 1/3] Remove bogus if-statement from pkgbase_delete()
The variable $action is always undefined in pkgbase_delete() which makes the if-statement always true and triggers a warning whenever a package base is removed. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/pkgbasefuncs.inc.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 57b307d..b20c2ff 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -522,15 +522,13 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via, $grant=false) { } /* Scan through pending deletion requests and close them. */ - if (!$action) { - $username = username_from_sid($_COOKIE['AURSID']); - foreach ($base_ids as $base_id) { - $pkgreq_ids = array_merge(pkgreq_by_pkgbase($base_id)); - foreach ($pkgreq_ids as $pkgreq_id) { - pkgreq_close(intval($pkgreq_id), 'accepted', - 'The user ' . $username . - ' deleted the package.', true); - } + $username = username_from_sid($_COOKIE['AURSID']); + foreach ($base_ids as $base_id) { + $pkgreq_ids = array_merge(pkgreq_by_pkgbase($base_id)); + foreach ($pkgreq_ids as $pkgreq_id) { + pkgreq_close(intval($pkgreq_id), 'accepted', + 'The user ' . $username . + ' deleted the package.', true); } } -- 2.12.0
Only show the comment paragraph if the package base is actually flagged out-of-date. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/template/flag_comment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/template/flag_comment.php b/web/template/flag_comment.php index e8855fe..05eeacb 100644 --- a/web/template/flag_comment.php +++ b/web/template/flag_comment.php @@ -11,11 +11,13 @@ '<strong>', htmlspecialchars($pkgbase_name), '</strong>'); ?> <?php endif; ?> </p> + <?php if (isset($message['Username'])): ?> <p> <div class="article-content"> <blockquote><p><?= parse_comment($message['FlaggerComment']) ?></p></blockquote> </div> </p> + <?php endif; ?> <p> <form action="<?= htmlspecialchars(get_pkgbase_uri($pkgbase_name), ENT_QUOTES) ?>"> <input type="submit" value="<?= __("Return to Details") ?>" /> -- 2.12.0
Do not trigger a PHP warning if there are no votes to be added or removed. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/pkgbasefuncs.inc.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index b20c2ff..cd4b271 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -735,6 +735,8 @@ function pkgbase_vote ($base_ids, $action=true) { $uid = uid_from_sid($_COOKIE["AURSID"]); $first = 1; + $vote_ids = ""; + $vote_clauses = ""; foreach ($base_ids as $pid) { if ($action) { $check = !isset($my_votes[$pid]); @@ -758,22 +760,24 @@ function pkgbase_vote ($base_ids, $action=true) { } } - /* Only add votes for packages the user hasn't already voted for. */ - $op = $action ? "+" : "-"; - $q = "UPDATE PackageBases SET NumVotes = NumVotes $op 1 "; - $q.= "WHERE ID IN ($vote_ids)"; + if (!empty($vote_ids)) { + /* Only add votes for packages the user hasn't already voted for. */ + $op = $action ? "+" : "-"; + $q = "UPDATE PackageBases SET NumVotes = NumVotes $op 1 "; + $q.= "WHERE ID IN ($vote_ids)"; - $dbh->exec($q); + $dbh->exec($q); - if ($action) { - $q = "INSERT INTO PackageVotes (UsersID, PackageBaseID, VoteTS) VALUES "; - $q.= $vote_clauses; - } else { - $q = "DELETE FROM PackageVotes WHERE UsersID = $uid "; - $q.= "AND PackageBaseID IN ($vote_ids)"; - } + if ($action) { + $q = "INSERT INTO PackageVotes (UsersID, PackageBaseID, VoteTS) VALUES "; + $q.= $vote_clauses; + } else { + $q = "DELETE FROM PackageVotes WHERE UsersID = $uid "; + $q.= "AND PackageBaseID IN ($vote_ids)"; + } - $dbh->exec($q); + $dbh->exec($q); + } if ($action) { return array(true, __("Your votes have been cast for the selected packages.")); -- 2.12.0
participants (1)
-
Lukas Fleischer