Problem/Motivation
Follow up to #2313917: Core version key in module's .info.yml doesn't respect core semantic versioning
In that issue we caught exceptions thrown by \Composer\Semver\Semver::satisfies()
and just return false.
This means any malformed version constraint in the new core_version_requirement
key will just result in core_incompatible === FALSE
in info.
The original reason I put this logic in was because we were actually using the existing core
key and unknown values would not throw an exception but just make the module uninstallable. So if we changed this behavior and throw and exception this would mean any current site that had bad value in some info.yml fail some would suddenly not be able to use the modules form page.
When we switched from using the existing core
to core_version_requirement
we really need to catch this exception because the chance of existing site having the core_version_requirement
key is very low.
Further it could cause a problem that developer might miss. For instance if you are updating your module that has some some modules but you currently don't have all the sub modules enabled you could accidentally change the value core_version_requirement
in one of the sub-modules, say if you had the file open to just change the title or description but didn't have it enabled. Since there is no exception thrown you could easily commit that change.
Proposed resolution
Remove \Drupal\Core\Extension\InfoParserDynamic::satisfies()
entirely and just call \Composer\Semver\Semver::satisfies()
directly instead.
This would thrown an exception if there was a malformed value in core_version_requirement
and the developer would be alerted to fix this.
Remaining tasks
Patch, review
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
None needed.
Comment | File | Size | Author |
---|---|---|---|
#10 | 3078001-10.patch | 716 bytes | Gábor Hojtsy |
#5 | 3078001-5.patch | 5.15 KB | tedbow |
#5 | interdiff-5.txt | 1.46 KB | tedbow |
#5 | 3078001-5-8.7.patch | 5.08 KB | tedbow |
#2 | 3078001-2-8.7.patch | 3.92 KB | tedbow |
Comments
Comment #2
tedbowPatches
Comment #3
tedbowWe actually didn't need this try/catch because the
static::satisfies()
already catches the exception 🤷♂️Comment #4
Wim LeersLooks good, but this needs an explicit test that shows that invalid values do trigger a particular expected exception.
Comment #5
tedbowComment #6
Wim LeersThe space before the period can be fixed on commit.
Comment #9
catchFixed the space and committer/pushed to 8.7/8.8
Comment #10
Gábor HojtsyI was about to fix this on commit, so doing a followup commit :)