Closed (fixed)
Project:
Project
Version:
7.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Apr 2010 at 09:07 UTC
Updated:
26 Aug 2013 at 18:44 UTC
Jump to comment: Most recent file
Comments
Comment #1
dwwSadly, version_compare() won't help us. However, there's a lot of logic and functionality in Project* for properly sorting complex version strings. Sadly, that logic isn't yet used consistently (it's all been a work-in-progress). See the big @TODO comment above project_release_get_releases() in project_release.module.
What we really need is to remove project_release_get_releases() entirely, and probably further refactor project_release_query_releases_by_branch() into something like project_release_query_releases() that lets you either filter or sort by branch. You still have to define the project id. But, if you leave the $api_tid or $major as NULL, it adds the corresponding DB column to the ORDER BY, not the WHERE (or something like that -- not sure exactly what the most intuitive API would be).
Comment #2
salvisThe one problem I've seen with version_compare() is that it doesn't sort the 'x' as we need it, but this can be fixed. I've tried the following, taking the release strings from Devel and adding some more:
This seems to work perfectly.
I don't have any project data to test it, but the attached patch should put it into practice.
Comment #3
wojtha commentedThere is same problem in translation interface in localize.drupal.org (l10n_server module). See #790722: Version order in translation form is confusing.
@Salvis Nice, this sorting function seems promising! I used similar approach, but with my own version parser. Usage of version_compare is (at least) undoubtly faster.
Comment #4
sunConfirmed, quite annoying.
We can test $a == $b prior to string replacements already.
Aside from that, this patch makes sense and is badly needed. Not sure whether it fixes all locations where versions are listed though.
--
That said, doesn't natsort() cut it already...?!
Comment #5
salvis@sun: You're right, natsort() does it (almost). array_reverse() does the rest. Much better, of course, thanks!
I have no idea whether there are any other locations that need fixing elsewhere, but I'd be happy to fix this one and see what happens.
As I already mentioned in #2, I can't actually test this because I don't have any project data/installation.
Comment #6
dwwhttp://drupal.org/project/drupalorg_testing
;)
Comment #7
salvisNice, but kind of overkill, given the complexity of the patch. I'm sure someone can test this with less effort...
:)
Comment #8
dww@salvis: There's no giant team of "someone" who works in the Project* issue queues testing things. There are 2 maintainers, 1 amazing contributor (right now) and an very tiny group of other people who help out at various times. We're all extremely busy. The whole point of this distro is to make it really trivial to have a useful test site so you don't have an excuse not to test your work. ;) You download a single tarball, unpack it in a webroot, visit install.php and you're done. I hope that's not too much to ask...
Comment #9
salvisOk, I tested this, and the result is that natsort() doesn't work, because it discards the keys. We need a sort function that preserves the keys, because they are the project version IDs.
So here's the patch from #2 with sun's suggested tweak.
This sorts the drop-down list correctly and keeps it working.
Comment #10
sunDoes this also affect the version select list on issue comment forms, as visible on this very page?
Comment #11
salvisYes, that's the one I'm targetting. Are there others? Where?
Comment #12
salvis@dww: Ok, so in #8 you nudged me into spending another hour on this, with the result that the patch in #9 is pretty much the same as the one in #2 was.
I realize that my time is not as valuable as yours, but it would still be nice to see that I haven't completely wasted it...
Comment #13
salvisSo, can someone review and RTBC this, please?
Comment #14
tr commentedSubscribing. I'll try to test the patch in the next few days.
Comment #15
wojtha commentedSalvis's proposed algorithm was commited to the Localize server project so this code has being tested at localize.drupal.org for year now... #790722-6: Version order in translation form is confusing
Comment #16
quicksketchPatch still applies and works flawlessly. Tested on a local environment with a plethora of version numbers, different API, major, minor, patch, and extra data; everything sorts perfectly. This would be a huge boost to accurate bug reports on drupal.org. I get at *least* 10 reports a week that are improperly filed in the queue because the latest version number is muddled somewhere in the middle of the list. With Drupal core having minor releases exceeding 25, I imagine misfiling is common in the core queue as well.
Comment #17
sunre: #9 @salvis: natsort() discards keys? That's odd, because the var_dump() in #4 exposes that the array key associations are retained.
Comment #18
salvisYou are right, sun. I don't remember what I tested, it's been a while...
Now, natsort() sorts in ascending order — how do we reverse the array without losing the keys?
Comment #19
sun@see http://php.net/manual/en/function.array-reverse.php
Comment #20
salvisThanks, sun.
This seems to be part of the Project project now.
Comment #21
sunThanks!
Comment #22
dwwSorry for the delay here folks. ;) Life's been crazy. Anyway, we had a similar (only worse) bug in the D7 port, so I just resurrected this patch. Sadly, natsort() is confused by -beta1 and friends. So, we really did want #9, not #20. Committed and pushed to 6.x-1.x and 7.x-2.x branches. Already deployed on the D7 staging site: http://git7site.devdrupal.org/project/issues/views. Tagged it for live d.o deployment, that'll happen soonish.
Thanks!
-Derek
Comment #23
salvisAh, life is great! :-)
Can't wait to see it...
Comment #24
senpai commentedThe next weekly drupal.org push-to-prd will happen this coming Thursday Oct 25th at 1:00pm PDT. If all is well, it could go out then. See the drupal.org calendar at https://drupal.org/website-schedule
Comment #26
drummDeployed.