Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 128561

Summary: PHP version info given in gentoo makes comparisons of versions fail
Product: Gentoo Linux Reporter: Arnaud Limbourg <arnaud>
Component: New packagesAssignee: PHP Bugs <php-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: High    
Version: 2006.0   
Hardware: All   
OS: Other   
Whiteboard:
Package list:
Runtime testing required: ---

Description Arnaud Limbourg 2006-04-02 13:24:07 UTC
Because php version info in gentoo has the form X.x.x-gentoo, comparisons done using version_compare() fail.

An example is when trying to install a pear package that requires a given php version:

 pear/PHPUnit2 requires PHP (version >= 5.1.2, version <= 6.0.0), installed version is 5.1.2-gentoo
 
# php -r "var_dump(version_compare('5.1.2', '5.1.2-gentoo'));"
int(1)

The solution is to modify the suffix to use either a numerical suffix or a patch level suffix

# php -r "var_dump(version_compare('5.1.2', '5.1.2-1'));"
int(-1)

# php -r "var_dump(version_compare('5.1.2', '5.1.2-p-gentoo'));"
int(-1)

The -1 means the right version is higher than the left one.

For more explanation please see

http://en.php.net/manual/en/function.version-compare.php
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2006-04-02 13:29:54 UTC
How did this bug make it back, been already fixed once. Yeah, it needs -pl? there.
Comment 2 Arnaud Limbourg 2006-04-02 13:35:42 UTC
This would work: 5.1.2-p-gentoo
Comment 3 Jakub Moc (RETIRED) gentoo-dev 2006-04-02 13:46:32 UTC
(In reply to comment #2)
> This would work: 5.1.2-p-gentoo

Yeah, it would, but it looks hell ugly. :P I prefer 5.1.2-pl1-gentoo :)
Comment 4 Arnaud Limbourg 2006-04-02 14:03:23 UTC
It works too :)

php -r "var_dump(version_compare('5.1.2', '5.1.2-pl1-gentoo'));"
int(-1) 
Comment 5 Luca Longinotti (RETIRED) gentoo-dev 2006-04-02 14:12:09 UTC
Ok, the -rX ebuilds are marked as VER-plX-gentoo, so those work, the problem is the zero revision (-r0) that's implicit, which gets VER-gentoo, and version_compare fails... I'll fix it so that a normal dev-lang/php-5.1.2 emerge will give you 5.1.2-pl0-gentoo, dev-lang/php-5.1.2-r1 will be 5.1.2-pl1-gentoo, and so on.
Best regards, CHTEKK.
Comment 6 Luca Longinotti (RETIRED) gentoo-dev 2006-04-18 05:53:26 UTC
Fixed now in CVS, done as I've stated in the previous comment.
Best regards, CHTEKK.