[aur-dev] [PATCH 1/2] Fix vote/notify link on the package details page
Call pkgbase_user_voted() and pkgbase_user_notify() using the package base ID instead of using the package ID. Fixes FS#40165. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgfuncs.inc.php | 11 ++++++----- web/template/pkg_details.php | 5 +++-- web/template/pkgbase_details.php | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index f800e34..a6fa32e 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -395,11 +395,12 @@ function pkg_name_is_blacklisted($name) { function pkg_get_details($id=0) { $dbh = DB::connect(); - $q = "SELECT Packages.*, PackageBases.Name AS BaseName, "; - $q.= "PackageBases.CategoryID, PackageBases.NumVotes, "; - $q.= "PackageBases.OutOfDateTS, PackageBases.SubmittedTS, "; - $q.= "PackageBases.ModifiedTS, PackageBases.SubmitterUID, "; - $q.= "PackageBases.MaintainerUID, PackageCategories.Category "; + $q = "SELECT Packages.*, PackageBases.ID AS BaseID, "; + $q.= "PackageBases.Name AS BaseName, PackageBases.CategoryID, "; + $q.= "PackageBases.NumVotes, PackageBases.OutOfDateTS, "; + $q.= "PackageBases.SubmittedTS, PackageBases.ModifiedTS, "; + $q.= "PackageBases.SubmitterUID, PackageBases.MaintainerUID, "; + $q.= "PackageCategories.Category "; $q.= "FROM Packages, PackageBases, PackageCategories "; $q.= "WHERE PackageBases.ID = Packages.PackageBaseID "; $q.= "AND PackageBases.CategoryID = PackageCategories.ID "; diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 7836596..791c9ee 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -3,6 +3,7 @@ $atype = account_from_sid($SID); $uid = uid_from_sid($SID); $pkgid = intval($row['ID']); +$base_id = intval($row['BaseID']); $catarr = pkgbase_categories(); @@ -73,7 +74,7 @@ $sources = pkg_sources($row["ID"]); </form> </li> <?php endif; ?> - <?php if (pkgbase_user_voted($uid, $row['ID'])): ?> + <?php if (pkgbase_user_voted($uid, $base_id)): ?> <li> <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unvote/'; ?>" method="post"> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> @@ -88,7 +89,7 @@ $sources = pkg_sources($row["ID"]); </form> </li> <?php endif; ?> - <?php if (pkgbase_user_notify($uid, $row['ID'])): ?> + <?php if (pkgbase_user_notify($uid, $base_id)): ?> <li> <form action="<?= get_pkgbase_uri($row['BaseName']) . 'unnotify/'; ?>" method="post"> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> diff --git a/web/template/pkgbase_details.php b/web/template/pkgbase_details.php index 83b474c..fd7bdad 100644 --- a/web/template/pkgbase_details.php +++ b/web/template/pkgbase_details.php @@ -49,7 +49,7 @@ $pkgs = pkgbase_get_pkgnames($base_id); </form> </li> <?php endif; ?> - <?php if (pkgbase_user_voted($uid, $row['ID'])): ?> + <?php if (pkgbase_user_voted($uid, $base_id)): ?> <li> <form action="<?= get_pkgbase_uri($row['Name']) . 'unvote/'; ?>" method="post"> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> @@ -64,7 +64,7 @@ $pkgs = pkgbase_get_pkgnames($base_id); </form> </li> <?php endif; ?> - <?php if (pkgbase_user_notify($uid, $row['ID'])): ?> + <?php if (pkgbase_user_notify($uid, $base_id)): ?> <li> <form action="<?= get_pkgbase_uri($row['Name']) . 'unnotify/'; ?>" method="post"> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> -- 1.9.2
This reverts commit 34453d32958cc71cf08e932368952f98b46b7020. Array fields are supposed to be handled like every other field: If a depends line appears in a package section, it replaces everything from the pkgbase section. Fixes FS#40166. --- web/html/pkgsubmit.php | 4 ++-- web/lib/aur.inc.php | 25 ------------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 180a0b2..5f56794 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -147,7 +147,7 @@ if ($uid): if (isset($section_info['pkgbase'])) { $pkgbase_info = $section_info; } elseif (isset($section_info['pkgname'])) { - $pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info); + $pkginfo[] = array_merge($pkgbase_info, $section_info); } } $section_info = array( @@ -189,7 +189,7 @@ if ($uid): if (isset($section_info['pkgbase'])) { $pkgbase_info = $section_info; } elseif (isset($section_info['pkgname'])) { - $pkginfo[] = array_pkgbuild_merge($pkgbase_info, $section_info); + $pkginfo[] = array_merge($pkgbase_info, $section_info); } } else { /* Use data from the PKGBUILD parser (deprecated!) */ diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index b41b720..16aa261 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -572,28 +572,3 @@ function latest_pkgs($numpkgs) { return $packages; } - -/** - * Merge pkgbase and package options - * - * Merges entries of the first and the second array. If any key appears in both - * arrays and the corresponding value is an array itself, the arrays are - * merged. If a key appears in both arrays and the corresponding value is not - * an array, the second value replaces the first one. - * - * @param array $pkgbase_info Options from the pkgbase section - * @param array $section_info Options from the package section - * - * @return array Merged information from both sections - */ -function array_pkgbuild_merge($pkgbase_info, $section_info) { - $pi = $pkgbase_info; - foreach ($section_info as $opt_key => $opt_val) { - if (is_array($opt_val)) { - $pi[$opt_key] += $opt_val; - } else { - $pi[$opt_key] = $opt_val; - } - } - return $pi; -} -- 1.9.2
If a depends (makedepends, checkdepends, optdepends, conflicts, provides, replaces, license, groups, source) line appears in a package section, it replaces the corresponding array from the pkgbase section. If there is a single "depends = " line in the package section, the depends array of that package is considered empty. This partly reverts the behavior introduced in commit 137a9ae (Fix parsing of array overrides, 2014-05-03). Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- This is supposed to replace patch 2/2 (Revert "Handle pkgbase array overrides gracefully"). web/html/pkgsubmit.php | 2 +- web/lib/aur.inc.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 180a0b2..7b7023b 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -135,7 +135,7 @@ if ($uid): $pkginfo = array(); $section_info = array(); foreach (explode("\n", $srcinfo_raw) as $line) { - $line = trim($line); + $line = ltrim($line); if (empty($line) || $line[0] == '#') { continue; } diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php index b41b720..ff46455 100644 --- a/web/lib/aur.inc.php +++ b/web/lib/aur.inc.php @@ -577,9 +577,12 @@ function latest_pkgs($numpkgs) { * Merge pkgbase and package options * * Merges entries of the first and the second array. If any key appears in both - * arrays and the corresponding value is an array itself, the arrays are - * merged. If a key appears in both arrays and the corresponding value is not - * an array, the second value replaces the first one. + * arrays and the corresponding value in the second array is either a non-array + * type or a non-empty array, the value from the second array replaces the + * value from the first array. If the value from the second array is an array + * containing a single empty string, the value in the resulting array becomes + * an empty array instead. If the value in the second array is empty, the + * resulting array contains the value from the first array. * * @param array $pkgbase_info Options from the pkgbase section * @param array $section_info Options from the package section @@ -590,7 +593,11 @@ function array_pkgbuild_merge($pkgbase_info, $section_info) { $pi = $pkgbase_info; foreach ($section_info as $opt_key => $opt_val) { if (is_array($opt_val)) { - $pi[$opt_key] += $opt_val; + if ($opt_val == array('')) { + $pi[$opt_key] = array(); + } elseif (count($opt_val) > 0) { + $pi[$opt_key] = $opt_val; + } } else { $pi[$opt_key] = $opt_val; } -- 1.9.2
participants (1)
-
Lukas Fleischer