In LocalFile normalize integer fields to integers
authorTim Starling <tstarling@wikimedia.org>
Wed, 2 Sep 2015 06:07:38 +0000 (16:07 +1000)
committerOri.livneh <ori@wikimedia.org>
Mon, 7 Sep 2015 06:50:35 +0000 (06:50 +0000)
File::getWidth() etc. should return an integer not a numeric string.

Bug: T111089
Change-Id: Ic767fb6cf3db0be9810b7bfa369c209ec05a6e58

includes/filerepo/file/LocalFile.php

index 4070553..d2c37e6 100644 (file)
@@ -502,9 +502,17 @@ class LocalFile extends File {
                        $decoded['mime'] = $decoded['major_mime'] . '/' . $decoded['minor_mime'];
                }
 
-               # Trim zero padding from char/binary field
+               // Trim zero padding from char/binary field
                $decoded['sha1'] = rtrim( $decoded['sha1'], "\0" );
 
+               // Normalize some fields to integer type, per their database definition.
+               // Use unary + so that overflows will be upgraded to double instead of
+               // being trucated as with intval(). This is important to allow >2GB
+               // files on 32-bit systems.
+               foreach ( array( 'size', 'width', 'height', 'bits' ) as $field ) {
+                       $decoded[$field] = +$decoded[$field];
+               }
+
                return $decoded;
        }