From 16cda58ff85aa3ae3534a2fe1fd0c998e01e8bb4 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 29 Jul 2011 23:49:12 +0200 Subject: Fix empty depends database insert Do not try to insert a falsey value into the database in case of "depends=()". Signed-off-by: Manuel Signed-off-by: Lukas Fleischer --- web/html/pkgsubmit.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'web/html/pkgsubmit.php') diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index fd51c7ef..793f8ca8 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -361,20 +361,25 @@ if ($uid): # Update package depends $depends = explode(" ", $new_pkgbuild['depends']); - foreach ($depends as $dep) { - $deppkgname = preg_replace("/(<|<=|=|>=|>).*/", "", $dep); - $depcondition = str_replace($deppkgname, "", $dep); + if ($depends !== false) { + foreach ($depends as $dep) { + $deppkgname = preg_replace("/(<|<=|=|>=|>).*/", "", $dep); + $depcondition = str_replace($deppkgname, "", $dep); - if ($deppkgname == "#") { - break; - } + if ($deppkgname == "") { + continue; + } + else if ($deppkgname == "#") { + break; + } - $q = sprintf("INSERT INTO PackageDepends (PackageID, DepName, DepCondition) VALUES (%d, '%s', '%s')", - $packageID, - mysql_real_escape_string($deppkgname), - mysql_real_escape_string($depcondition)); + $q = sprintf("INSERT INTO PackageDepends (PackageID, DepName, DepCondition) VALUES (%d, '%s', '%s')", + $packageID, + mysql_real_escape_string($deppkgname), + mysql_real_escape_string($depcondition)); - db_query($q, $dbh); + db_query($q, $dbh); + } } # Insert sources -- cgit v1.2.3-24-g4f1b