[TYPO3-core] phpversion() vs PHP_VERSION
Michael Stucki
michael at typo3.org
Wed Jun 7 11:30:37 CEST 2006
Hi Martin,
>>>>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?
Well, that was nonsense of course. Indeed it works because floatval('4.0.0')
returns 4, but the problem here is that this does not allow beta and RC
version numbers anymore...
>> 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.
I meant this:
| > echo version_compare('4.1rc4', '4.1beta3', 'le') ? 'yes' : 'no';
| > Why does this return "yes"?
|
| I tested a few strings and found the function to be case sensitive.
| You have to stick to these strings (whatever "pl" may be):
|
| dev < alpha
Of course one could say: Let's just stick to these rules and everything will
work as expected.
On the other side, I doubt that the EM will then often perform wrong checks
because extension authors didn't know about these rules...
As long as this doesn't work, I'm in favour of our own - more flexible -
version comparing function (actually it's only converting, not comparing).
>> 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
OK, changed.
> 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.
done
> As for the rewriting of int_from_ver(): It is wrong. You must not use
> round() on a version number!
It worked because all float numbers were higher than 0.5 - but I've changed
this to ceil() now.
> 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?
I've extended the function so that it can even differ between build version
numbers (e.g. I'm running PHP 4.3.10-16).
If we introduce the new version, then we should use it all over the place...
See attached patch.
> 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.
It's just a question of flexibility. If we sort out the 4.0 < 4.0.0 error in
the next version, that will be ok as well.
- michael
--
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typo3_version_HEAD_v2.diff
Type: text/x-diff
Size: 4652 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20060607/b7fb84ba/attachment.bin
More information about the TYPO3-team-core
mailing list