From: Ævar Arnfjörð Bjarmason Date: Mon, 9 May 2005 16:14:00 +0000 (+0000) Subject: * Switching is_numeric() in isByte(), isShort() and isLong() out for sprintf() X-Git-Tag: 1.5.0alpha2~238 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=063b4fe03af2f828776a697c9ef8571460732cfa;p=lhc%2Fweb%2Fwiklou.git * Switching is_numeric() in isByte(), isShort() and isLong() out for sprintf() per wegges suggestion because: 1. $in can't be a floating point number 2. When typecast php ignores any non-integers after the first row of integers 3. A regular expression would be slower and insanely complex * Insert kind comments about php and remarks about how much I appriciate its existance here* --- diff --git a/includes/Exif.php b/includes/Exif.php index e0b67275e1..f62dbc80ab 100644 --- a/includes/Exif.php +++ b/includes/Exif.php @@ -305,7 +305,7 @@ class Exif { */ function isByte( $in ) { $fname = 'isByte'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 255 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 255 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else { @@ -321,7 +321,7 @@ class Exif { function isShort( $in ) { $fname = 'isShort'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 65536 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 65536 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else { @@ -332,7 +332,7 @@ class Exif { function isLong( $in ) { $fname = 'isLong'; - if ( is_numeric( $in ) && $in >= 0 && $in <= 4294967296 ) { + if ( sprintf('%d', $in) === $in && $in >= 0 && $in <= 4294967296 ) { wfDebug("Exif::$fname: accepted: '$in' (type: " . gettype( $in ) . ")\n"); return true; } else {