[TYPO3-core] phpversion() vs PHP_VERSION

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Wed Jun 7 10:13:08 CEST 2006


Michael Stucki schrieb:
> Martin Kutschker wrote:
> 
> 
>>>No, the EM obviously complains about "4.0" not being good enough for an
>>>extension asking for "4.0.0". Doesn't it for you?
>>
>>I don't know, but I meant it *should* be treated as a shorthand. IMHO "4",
>>"4.0" and "4.0.0" are the same version and should be treated by the EM
>>(and int_from_ver as such).
> 
> 
> I think the problem is that the values must not be submitted as strings.
> Using the floatval() function it works as expected (which seems obvious to
> me, somehow...)

Huh? Where?

> Unfortunately, this is not the only problem. See my other mail from this
> afternoon. I think it's better to stick with our own function, an improved
> version of the int_from_ver() method in t3lib_div.

I don't get which mail you mean. I see no reason to create yet another 
version comparing function when we have a built-in php function for it.

> Attached is a patch that replaces t3lib_div::int_from_ver() with
> t3lib_div::flatVersionNumber(). It works as expected with every kind of
> version string (4.1-cvs, 4.0.2beta3, etc.).
> 
> The big difference compared to the int_from_ver() function is just that it
> respects CVS, beta and RC candidates as expected:
> 
> 4.1-cvs (=.1.0-cvs) results in 4000999.6
> 4.0.2rc3 becomes 4000001.903
> 4 becomes 4000000
> 
> ... and finally, those numbers can easily be compared using mathematical
> operators <|=.
> 
> Please have a look at the patch and let me know if you consider it as
> useful :-)

Well, flatVersionNumber() is - in a way nice, but I would use a slightly 
different scheme for the "sub-version":

x.y.z-Tn => xxxyyyzzz.tnnn

the digit "t" depends on the "tag":

cvs 1
dev 2 (we could deliver weekly/monthly snapshots with this "tag")
alpha 3
beta 4
gamma 5 (Mysql sporst such numbers)
RC 6

And perhaps it should be named float_from_ver() to be in line with the 
older function. Also a, b and g could be shorthands for alpha, beta and gamma.

As for the rewriting of int_from_ver(): It is wrong. You must not use 
round() on a version number!

When comparing php version numbers we should stick to version_compare(). 
Why use two PHP homebrew functions calls when we can use on built-in one?

Summary the new function is IMHO only partial useful and necessary. As IMHO 
real life extensions should not rely on "sub version" tags int_from_ver() 
is good enough. If not, php_version() is readily available if we move from 
"cvs" to "dev" and write "rc" in caps.

-1 to the rewriting of int_from_ver() [wrong] and the PHP version check 
with the new function [waste of CPU cycles].

> Additionally, I suggest to change the version number in TYPO3_4-0 CVS as
> follows:
> 
> --- t3lib/config_default.php    4 Jun 2006 16:15:06 -0000       1.86.2.29
> +++ t3lib/config_default.php    6 Jun 2006 10:47:14 -0000
> @@ -247,7 +247,7 @@
>  $T3_VAR =rray();     // Initialize.
> 
>         // TYPO3 version
> -$TYPO_VERSION =4.0-CVS';     // deprecated: use the constants defined below
> +$TYPO_VERSION =4.0.1-cvs';   // deprecated: use the constants defined below
>  define('TYPO3_version', $TYPO_VERSION);

Yes, for 4.0.1, but I'd prefer a change to -dev. Anyway, in a few days it 
should be 4.0.2-ttt :-)

Masi



More information about the TYPO3-team-core mailing list