* Switching is_numeric() in isByte(), isShort() and isLong() out for sprintf()
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Mon, 9 May 2005 16:14:00 +0000 (16:14 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Mon, 9 May 2005 16:14:00 +0000 (16:14 +0000)
  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*

includes/Exif.php

index e0b6727..f62dbc8 100644 (file)
@@ -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 {