summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-04-28 19:28:23 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-06-26 08:53:55 +0200
commitfbf3e5405781f0f7ded67e99ab83bebc0737499d (patch)
treef1e0a2ea3259f8f7455e4a1839be1908d42808ab /web/lib
parent0350de4b422b06e99ce769ba03d451577ecb0ee8 (diff)
downloadaurweb-fbf3e5405781f0f7ded67e99ab83bebc0737499d.tar.xz
Add hard limit for the length of dependency lists
Introduce a configuration option max_depends which can be used to specify a maximum number of (reverse) dependencies to display on the package details pages. Fixes FS#49059. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgfuncs.inc.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index eaea318..4b0fdba 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -230,10 +230,11 @@ function pkg_providers($name) {
* Get package dependencies for a specific package
*
* @param int $pkgid The package to get dependencies for
+ * @param int $limit An upper bound for the number of packages to retrieve
*
* @return array All package dependencies for the package
*/
-function pkg_dependencies($pkgid) {
+function pkg_dependencies($pkgid, $limit) {
$deps = array();
$pkgid = intval($pkgid);
if ($pkgid > 0) {
@@ -243,7 +244,7 @@ function pkg_dependencies($pkgid) {
$q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) = p.Name ";
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
- $q.= "ORDER BY pd.DepName";
+ $q.= "ORDER BY pd.DepName LIMIT " . intval($limit);
$result = $dbh->query($q);
if (!$result) {
return array();
@@ -505,10 +506,11 @@ function pkg_source_link($url, $arch) {
*
* @param string $name The package name for the dependency search
* @param array $provides A list of virtual provisions of the package
+ * @param int $limit An upper bound for the number of packages to retrieve
*
* @return array All packages that depend on the specified package name
*/
-function pkg_required($name="", $provides) {
+function pkg_required($name="", $provides, $limit) {
$deps = array();
if ($name != "") {
$dbh = DB::connect();
@@ -523,7 +525,7 @@ function pkg_required($name="", $provides) {
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.DepName IN (" . $name_list . ") ";
$q.= "OR SUBSTRING(pd.DepName FROM 1 FOR POSITION(': ' IN pd.DepName) - 1) IN (" . $name_list . ") ";
- $q.= "ORDER BY p.Name";
+ $q.= "ORDER BY p.Name LIMIT " . intval($limit);
$result = $dbh->query($q);
if (!$result) {return array();}
while ($row = $result->fetch(PDO::FETCH_NUM)) {