[aur-dev] [PATCH v2 1/2] aurjson.class.php: Fix "Undefined index" notices
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- Use isset() instead of array_key_exists() as suggested by Florian. web/lib/aurjson.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index e646c63..304a50a 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -110,8 +110,8 @@ class AurJSON { return; } - $callback = $http_data['callback']; - if (isset($callback)) { + if (isset($http_data['callback'])) { + $callback = $http_data['callback']; if (!preg_match('/^[a-zA-Z0-9().]{1,128}$/D', $callback)) { return $this->json_error('Invalid callback name.'); } @@ -281,11 +281,15 @@ class AurJSON { * proper data types in the JSON response. */ foreach (self::$numeric_fields as $field) { - $row[$field] = intval($row[$field]); + if (isset($row[$field])) { + $row[$field] = intval($row[$field]); + } } foreach (self::$decimal_fields as $field) { - $row[$field] = floatval($row[$field]); + if (isset($row[$field])) { + $row[$field] = floatval($row[$field]); + } } if ($this->version >= 2 && ($type == 'info' || $type == 'multiinfo')) { -- 2.5.3
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/lib/pkgfuncs.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index edc747b..66bc249 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -792,6 +792,7 @@ function pkg_search_page($SID="") { include('pkg_search_form.php'); + $searchresults = array(); if ($result) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $searchresults[] = $row; -- 2.5.3
participants (1)
-
Lukas Fleischer