Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 128561 - PHP version info given in gentoo makes comparisons of versions fail
Summary: PHP version info given in gentoo makes comparisons of versions fail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Other
: High normal (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-02 13:24 UTC by Arnaud Limbourg
Modified: 2006-04-18 05:53 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.