[TYPO3-dev] behaviour of t3lib_div::testInt has been changed

JoH asenau info at cybercraft.de
Thu Sep 9 15:24:42 CEST 2010


>>>>> I have observed that the behaviour of the function
>>>>> t3lib_div::testInt has been changed.
>>>> 
>>>> there was a very long discussion about this topic in the core list.
>>>> Have a look at RFC #15020.
>>> 
>>> as far as I see this should have been a performance improvement
>>> only. Obviously no test has been made for a string like '10.' as it
>>> comes from TypoScript.
>> 
>> And what would be the expected result in this case?
> 
> 10. is a floating point number - in java, in c, in php in javascript
> :) i would expect to get a false on testInt(), Franz is right there.

10.xx would be a floating point number, but it could be "interpreted as integer" as well (as long as there is no value > 0 after the dot), which is what the description of the function tells.
As far as I understood, this is why the function has been kept instead of replacing it with is_int() or something similar.
So 10.01 could not be "interpreted as integer", while 10.00 and 10. could.

So I guess that
a) the behaviour of the function was wrong before, if it returned a different value
b) the change actually is a bugfix and
c) the usage of testInt() to eliminate TS array keys containing a dot is no good idea at all, since there might be array keys like "blah." as well
d) strpos or substr would be preferrable here

Just my 2 cents

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-dev mailing list