[aur-dev] [PATCH] RPC: Add decimal_fields array for floating-point fields

Johannes Löthberg johannes at kyriasis.com
Sat Jul 4 10:31:41 UTC 2015


Fixes FS#45537.

Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
---
Another take on fixing FS#45537, makes 
<1435960231-22737-1-git-send-email-johannes at kyriasis.com>
obsolete

 web/lib/aurjson.class.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index 7b77da4..f73d0c0 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -45,6 +45,9 @@ class AurJSON {
 		'ID', 'PackageBaseID', 'NumVotes', 'OutOfDate',
 		'FirstSubmitted', 'LastModified'
 	);
+	private static $decimal_fields = array(
+		'Popularity'
+	);
 
 	/*
 	 * Handles post data, and routes the request.
@@ -255,6 +258,10 @@ class AurJSON {
 					$row[$field] = intval($row[$field]);
 				}
 
+				foreach (self::$decimal_fields as $field) {
+					$row[$field] = floatval($row[$field]);
+				}
+
 				if ($this->version >= 2 && ($type == 'info' || $type == 'multiinfo')) {
 					$row = array_merge($row, $this->get_extended_fields($row['ID']));
 				}
-- 
2.4.5


More information about the aur-dev mailing list