[aur-dev] [PATCH] RPC: Coerce numeric values into integers

Dave Reisner d at falconindy.com
Sat Aug 20 19:57:20 EDT 2011


On Sun, Aug 21, 2011 at 01:51:44AM +0200, Lukas Fleischer wrote:
> Coerce "ID", "FirstSubmitted" and "LastModified" into integers to ensure
> json_encode() serializes them as numeric values. This means that there
> will be a minor API break. There doesn't seem to be a better way to do
> this properly, though. Fixes FS#25693.
> 
> Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
> ---
>  web/lib/aurjson.class.php |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
> index 277c824..ad99529 100644
> --- a/web/lib/aurjson.class.php
> +++ b/web/lib/aurjson.class.php
> @@ -126,6 +126,9 @@ class AurJSON {
>              while ( $row = mysql_fetch_assoc($result) ) {
>                  $name = $row['Name'];
>                  $row['URLPath'] = URL_DIR . substr($name, 0, 2) . "/" . $name . "/" . $name . ".tar.gz";
> +                $row['ID'] = intval($row['ID']);
> +                $row['FirstSubmitted'] = intval($row['FirstSubmitted']);
> +                $row['LastModified'] = intval($row['LastModified']);
>  
>                  if ($type == 'info') {
>                      $search_data = $row;
> -- 
> 1.7.6
> 

I suppose I was a bit hasty in my bug report. If we're going to break
things, can we break even more? There's no reason we couldn't also
coerce: CategoryID, NumVotes, and OutOfDate (which might be better as a
boolean).

d


More information about the aur-dev mailing list