[aur-dev] [PATCH 1/2] Fix processing of pkgbase_get_comaintainers()
pkgbase_get_comaintainers() returns an array of user names, not an array of user IDs. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/pkgdisown.php | 6 +++--- web/lib/pkgbasefuncs.inc.php | 15 +++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/web/html/pkgdisown.php b/web/html/pkgdisown.php index 071a76c..fa182dc 100644 --- a/web/html/pkgdisown.php +++ b/web/html/pkgdisown.php @@ -11,7 +11,7 @@ check_sid(); html_header(__("Disown Package")); $maintainer_uids = array(pkgbase_maintainer_uid($base_id)); -$comaintainer_uids = pkgbase_get_comaintainers($base_id); +$comaintainers = pkgbase_get_comaintainers($base_id); if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?> <div class="box"> @@ -26,9 +26,9 @@ if (has_credential(CRED_PKGBASE_DISOWN, $maintainer_uids)): ?> <?php endforeach; ?> </ul> <p> - <?php if (count($comaintainer_uids) > 0): ?> + <?php if (count($comaintainers) > 0): ?> <?= __('By selecting the checkbox, you confirm that you want to disown the package and transfer ownership to %s%s%s.', - '<strong>', $comaintainer_uids[0], '</strong>'); ?> + '<strong>', $comaintainers[0], '</strong>'); ?> <?php else: ?> <?= __('By selecting the checkbox, you confirm that you want to disown the package.') ?> <?php endif; ?> diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index b8da23c..5b8b52f 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -646,12 +646,15 @@ function pkgbase_adopt ($base_ids, $action=true, $via) { } } else { foreach ($base_ids as $base_id) { - $uids = pkgbase_get_comaintainers($base_id); - - $q = "UPDATE PackageBases "; - $q.= "SET MaintainerUID = " . $uids[0] . " "; - $q.= "WHERE ID = " . $base_id; - $dbh->exec($q); + $comaintainers = pkgbase_get_comaintainers($base_id); + + if (count($comaintainers) > 0) { + $uid = uid_from_username($comaintainers[0]); + $q = "UPDATE PackageBases "; + $q.= "SET MaintainerUID = " . $uid . " "; + $q.= "WHERE ID = " . $base_id; + $dbh->exec($q); + } } } } -- 2.4.1
When a user disowns a package and promotes a co-maintainer, remove that new maintainer from the list of package co-maintainers. Since only the package maintainer can manage co-maintainers, this must happen before the actual disown operation. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/pkgbasefuncs.inc.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 5b8b52f..327b7f9 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -629,32 +629,39 @@ function pkgbase_adopt ($base_ids, $action=true, $via) { } } - $q = "UPDATE PackageBases "; + /* Adopt or disown the package. */ if ($action) { + $q = "UPDATE PackageBases "; $q.= "SET MaintainerUID = $uid "; + $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") "; + $dbh->exec($q); } else { - $q.= "SET MaintainerUID = NULL "; - } - $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") "; - $dbh->exec($q); - - /* Update package co-maintainers when disowning a package. */ - if (!$action) { + /* Update the co-maintainer list when disowning a package. */ if (has_credential(CRED_PKGBASE_DISOWN)) { foreach ($base_ids as $base_id) { - pkgbase_set_comaintainers($base_id, ""); + pkgbase_set_comaintainers($base_id, array()); } + + $q = "UPDATE PackageBases "; + $q.= "SET MaintainerUID = NULL "; + $q.= "WHERE ID IN (" . implode(",", $base_ids) . ") "; + $dbh->exec($q); } else { foreach ($base_ids as $base_id) { $comaintainers = pkgbase_get_comaintainers($base_id); if (count($comaintainers) > 0) { $uid = uid_from_username($comaintainers[0]); - $q = "UPDATE PackageBases "; - $q.= "SET MaintainerUID = " . $uid . " "; - $q.= "WHERE ID = " . $base_id; - $dbh->exec($q); + $comaintainers = array_diff($comaintainers, array($comaintainers[0])); + pkgbase_set_comaintainers($base_id, $comaintainers); + } else { + $uid = "NULL"; } + + $q = "UPDATE PackageBases "; + $q.= "SET MaintainerUID = " . $uid . " "; + $q.= "WHERE ID = " . $base_id; + $dbh->exec($q); } } } -- 2.4.1
participants (1)
-
Lukas Fleischer