Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up from #211747: Allow specifying version information as part of module dependencies...
That patch does not properly support versions with "extra": alpha, beta, rc, etc. We need to add some more code to handle this.
Also, I'm pretty sure PHP's version_compare() is going to barf on "unstable", which is another allowed "extra" identifier on version strings which is a drupalism. Not sure if we care, but perhaps we'll need to special-case that, and if we see "unstable" to try to do our own version_compare() logic. That'd be a bit of a drag, but probably worth it.
Comment | File | Size | Author |
---|---|---|---|
#25 | version_dependency_extra.patch | 3.89 KB | chx |
#23 | version_dependency_extra.patch | 4.8 KB | chx |
#22 | version_dependency_extra.patch | 3.9 KB | chx |
#21 | version_dependency_extra.patch | 4.44 KB | chx |
#13 | version_dependencies.patch | 3.68 KB | chx |
Comments
Comment #1
Paul Natsuo Kishimoto CreditAttribution: Paul Natsuo Kishimoto commented#211747-78: Allow specifying version information as part of module dependencies
Comment #2
dwwIn the other comment (which I'm going to unpublish due to confusion), Paul wrote:
Re: points B and C: read http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version. It seems here it would work to interpret an empty part as zero ("2.4" is "2.4-0") and ensure a numerical part sorts later (i.e. is considered newer than) a part beginning with a letter ("alpha1" or "beta1").
Thus, in proper sort order:
2.4-beta1
2.4-rc1
2.4 (as "2.4-0")
2.5+cvs20090728 (as "2.5+cvs20090728-0"), a dev release. This is seen frequently in Debian & co.
2.5-alpha1 (as "2.5+0-alpha1")
2.5 (as "2.5-0")
...etc., so that:
Comment #4
dwwComment #5
sunPHP's version_compare() already handles extra identifiers in version numbers properly.
The only issue we'd have to tackle here is to transform branch versions, i.e.
2.x
, into a comparable version number for version_compare(), because2.x
is interpreted completely different than2.1-beta2
. The most trivial and most dirty way would be to transform2.x
into2.999
internally for comparison. That way:Comment #6
chx CreditAttribution: chx commentedsun, we already have code to handle 2.x -- and yes it can be changed so that preg is not necessary but that's a whole another issue -- and there is no 2.x-beta or some such so your followup does not pertain to this issue.
Comment #7
chx CreditAttribution: chx commentedtesting version compare for arbitrary strings:
both are TRUE.when using the same version string the comparison works well.
dev < alpha = a < beta = b < RC < pl
says the documentation which can now amend asarbitrary string < dev < alpha = a < beta = b < RC < pl
.Edit: I read the relevant C code and it converts these special strings to numbers so the order is:
any string not in the following list < dev < alpha = a < beta = b < RC = rc < # < pl = p
Comment #8
dwwgreat. so "unstable" == "any string not in the following list", and it honors our (suggested) ordering of things. Of course, nothing forces module maintainers to go in order from unstable to alpha to beta to rc, but we can't do anything about that (beyond education). Looks like this should be quite trivial...
Comment #9
sunOur version info is 6.x-2.x-dev, not 6.x-2.3-dev.
Comment #10
dwwThis is not about -dev. Screw -dev. This is about official releases only.
Comment #11
chx CreditAttribution: chx commentedNeeds tests. We had TONS of fun with version_compare.
Comment #13
chx CreditAttribution: chx commentedComment #15
chx CreditAttribution: chx commentedComment #16
Dries CreditAttribution: Dries commentedThis looks good to me. Should we add a couple more tests? I.e. comparing rc1 and rc2, comparing unstable with alpha, etc?
Comment #17
dwwYes, more tests would be very important, especially given how weird version_compare() is. ;) Should be trivial to add.
It's not clear to me why the special case to handle minor == 'x' only needs to deal with $op '>' and '<='. What about '>=' and '<'? Comment here would be useful, but probably a code comment explaining would be better.
Comment #18
chx CreditAttribution: chx commentedDerek, the >= and the < are dealt with the resetting of minor and extra. And there is a comment IMO which already explains that but I will check.
Comment #19
dww@chx: I'm talking about this:
I don't see how that's going to properly handle (>= 2.x) nor (< 2.x). Can you explain?
Thanks!
-Derek
Comment #20
dwwOh, I see now. But it's just a bit confusing. ;) Sorry.
Still needs work for more tests... Might not hurt to explain this code block better. I might re-roll later for that (but I can't right now).
Thanks,
-Derek
Comment #21
chx CreditAttribution: chx commentedMore tests, more comments.
Comment #22
chx CreditAttribution: chx commentedThis is a whole new approach because a question from Nick Lewis made me test 2.0 vs 2.x in version compare to find that numbers are higher than strings. Yay. Simplify++
Comment #23
chx CreditAttribution: chx commentedNow, that's some comment...
Comment #25
chx CreditAttribution: chx commentedSimplified comments -- we do not need a novel about internal implementation details. There is enough comment so that people can figure out if they want.
Comment #26
mikey_p CreditAttribution: mikey_p commentedLooks great, with one question.
What is the difference between the = and == operator? I couldn't find any docs on php.net on this, and not quite sure what it could be.
Since we allow this op, and special case it for .x version number, we should probably have a test for it.
Otherwise, RTBC
Comment #27
mikey_p CreditAttribution: mikey_p commentedActually after looking at this, I'm not sure the == operator makes much sense. In the case of 2.x it is identical to =.
With specific versions (not .x branches), we require the point release in dependency strings anyway*, and packaged releases will always have it as well, and we don't allow patch level, so there is no need to say 2.0.0 vs. 2.0 aren't equal.
*(>=2) doesn't work, must be 2.x
Comment #28
chx CreditAttribution: chx commented== and = are the very same. Why not allow both? version_compare allows both. There's not much point in testing that.
Comment #29
webchickThat looks MUCH better.
I made some more minor polish to the comments and committed to HEAD.
It looks like mikey_p was looking at a different hunk of this file that the patch doesn't touch. We could open a separate issue for that.