Problem/Motivation
At #2991207: Drupal core should inform the user of the security coverage for the site's installed minor version including final 8.x LTS releases, the latest patches are introducing a ProjectSecurityData::getSemanticMinorVersion() method to get the minor version out of a semantic version string. I've flagged this as weird in my reviews over there. We already have a ModuleVersion class for exactly this kind of thing. Let's put the code there, not in the new ProjectSecurityData class.
Proposed resolution
Add ModuleVersion::getMinorVersion() for use by ProjectSecurityData and others.
Remaining tasks
Write codeUpdate tests- Review
- RTBC
- Commit
User interface changes
N/A
API changes
Adds a new getMinorVersion() method to the (internal / final) ModuleVersion class.
(Also adds a $minor_version argument to the constructor, but that's already private so it doesn't matter).
Data model changes
N/A
Release notes snippet
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3110223-2.patch | 7.86 KB | dww |
Comments
Comment #2
dwwOkay, I guess it's a little more than 5 lines of code and 20 lines of tests. ;) But still, this seems way better than the alternative, and now we've got test coverage, too.
Comment #3
xjmAs @tedbow pointed out, we can't simply call the second number in the version string the minor version, because for pre-semver contrib releases (or pre-D8 core releases), the versions are just
major.patch. For that reason, I think this adds complexity/confusion and is wontfix for now.Comment #4
dww@xjm, thanks for the review. Some arguments in support of this patch:
...
Please don't won't fix. ;)
Thanks,
-Derek
Comment #5
xjmThe past 10 years of Drupal development, OTOH, do make it so. Also, the changes we allow in those versions make it so. Drupal 7 had basically no new features introduced after its release because each release (e.g. 7.67) followed semver guidelines for the allowed changes of patch releases. For this reason, any API addition here to consider minor or patch versions should also take this into account. Giving something the name "minor" when people in the community have called it a patch release for a decade is going to lead to confusion.
Therefore, this will need more thought put into any naming or documentation around minors and patches than what's in the patch currently.
This object is marked
@internalandfinalwith a private constructor. It's not meant for use for anything outside the update system. We can add additional properties to it if we want later, but we shouldn't just add them because we don't want a one-liner somewhere else without a second usecase and especially with the confusion described above.So, I am postponing this issue for now. We can revisit it if:
minor.patchversions" in a way that developers will understand by reading the method names.