diff options
Diffstat (limited to 'web/lib/aurjson.class.php')
-rw-r--r-- | web/lib/aurjson.class.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php index 6c7725c..234a3c4 100644 --- a/web/lib/aurjson.class.php +++ b/web/lib/aurjson.class.php @@ -18,11 +18,14 @@ class AurJSON { 'search', 'info', 'multiinfo', 'msearch' ); private static $fields = array( - 'Packages.ID', 'Name', 'Version', 'CategoryID', - 'Description', 'URL', 'License', - 'NumVotes', '(OutOfDateTS IS NOT NULL) AS OutOfDate', + 'Packages.ID', 'Name', 'Version', 'CategoryID', 'Description', 'URL', + 'License', 'NumVotes', 'OutOfDateTS AS OutOfDate', 'SubmittedTS AS FirstSubmitted', 'ModifiedTS AS LastModified' ); + private static $numeric_fields = array( + 'ID', 'CategoryID', 'NumVotes', 'OutOfDate', 'FirstSubmitted', + 'LastModified' + ); /** * Handles post data, and routes the request. @@ -127,6 +130,14 @@ class AurJSON { $name = $row['Name']; $row['URLPath'] = URL_DIR . substr($name, 0, 2) . "/" . $name . "/" . $name . ".tar.gz"; + /* Unfortunately, mysql_fetch_assoc() returns all fields as + * strings. We need to coerce numeric values into integers to + * provide proper data types in the JSON response. + */ + foreach (self::$numeric_fields as $field) { + $row[$field] = intval($row[$field]); + } + if ($type == 'info') { $search_data = $row; break; |