Commit 48ae7360 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

Prevent merging a package base with itself



Instead of deleting the package, show an error message if a user tries
to merge a package base with itself.

Signed-off-by: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent 446d4537
......@@ -69,12 +69,15 @@ if (check_token()) {
}
else {
$merge_base_id = pkgbase_from_name($_POST['merge_Into']);
if ($merge_base_id) {
list($ret, $output) = pkgbase_delete($ids, $merge_base_id, $via);
unset($_GET['ID']);
} else {
if (!$merge_base_id) {
$output = __("Cannot find package to merge votes and comments into.");
$ret = false;
} elseif (in_array($merge_base_id, $ids)) {
$output = __("Cannot merge a package base with itself.");
$ret = false;
} else {
list($ret, $output) = pkgbase_delete($ids, $merge_base_id, $via);
unset($_GET['ID']);
}
}
}
......
......@@ -110,6 +110,10 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
$base_id = intval($ids[0]);
$pkgbase_name = pkgbase_name_from_id($base_id);
if ($merge_into == $pkgbase_name) {
return array(false, __("Cannot merge a package base with itself."));
}
$q = "SELECT ID FROM RequestTypes WHERE Name = " . $dbh->quote($type);
$result = $dbh->query($q);
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment