Closed (fixed)
Project:
Localization server
Version:
6.x-2.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 May 2010 at 17:34 UTC
Updated:
9 Jun 2010 at 12:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
wojtha commentedMy fist suggestion is to create parser and score function which turn drupal version 7.x-1.0-alpha2 into some score like 7010003000 or so...
Comment #2
wojtha commentedFaster and cleaner implementation I believe :-)
Function "_drupal_version_score" converts drupal versions human readable strings which can be easily alphabetically sorted in the right order.
There is only one trick... stable versions are marked with "s" that makes them to be ordered after Alpha, Beta and RC versions.
E.g.:
0502001s00 <-- 5.x-2.1
0601009s00 <-- 6.x-1.9
0601010s00 <-- 6.x-1.10
0701000a01 <-- 7.x-1.0-alpha1
0701000a02 <-- 7.x-1.0-alpha2
0701000s00 <-- 7.x-1.0
0702001b13 <-- 7.x-2.1-beta13
0702001r01 <-- 7.x-2.1-RC1
0702002s00 <-- 7.x-2.2
Gábor let me know if you like it. I will try to turn it into patch...
Comment #3
gábor hojtsyHow does Drupal.org's project module do this? It has the same problems for the version dropdowns we have :) Also, PHP's version_compare() function has no usefulness here?
Comment #4
wojtha commentedHi Gabor,
Thx for your righteous comments and suggestions. Thing is moving forward!... I make some research of the project module. The sorting is done in Project issue tracking module, but it uses function project_release_get_releases() which resides in Project module. The function is using database alphabetic sorting and it has same wrong output in current implementation...
I found this issue: #767366: Sort version lists with version_compare() ... which is basically same problem and there is a fresh solution too.
Project module has had this prob for years and now there is a patch, which was submitted two weeks ago (salvis - April 10, 2010 - 21:30). Funny!
Salvis is also using version_compare() as you suggested. I don't like using str_replace in this way, but it is undoubtly faster than preg_match.
I made a test and sorting is right, but in opposite order - latest version is on the top. Which is also better I think.
Output from the Salvis's version_compare_function() seems very promising:
Comment #5
gábor hojtsyThe latest results look good. Should we wait on that patch to resolve itself, or is it good enough that we could just integrate it and maybe keep looking for changes to port here later? (I'm marking this needs work since we have some code here, not just talk :).
Comment #6
wojtha commentedHi Gabor,
here is a tiny patch which fixes it.
Credits for using version_compare() are going to salvis.
Comment #7
gábor hojtsyGreat, thanks, committed.