From: Tim Starling Date: Wed, 2 Sep 2015 06:07:38 +0000 (+1000) Subject: In LocalFile normalize integer fields to integers X-Git-Tag: 1.31.0-rc.0~10126^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22statistiques_visites%22%2C%22%22%29%20.%20%22?a=commitdiff_plain;h=b4b64c82c8eac1751862c69a85386cb1fd7086f5;p=lhc%2Fweb%2Fwiklou.git In LocalFile normalize integer fields to integers File::getWidth() etc. should return an integer not a numeric string. Bug: T111089 Change-Id: Ic767fb6cf3db0be9810b7bfa369c209ec05a6e58 --- diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 40705532a7..d2c37e614c 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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; }