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.
Problem/Motivation
\Drupal\Core\Extension\InfoParserDynamic::parse() calls \Composer\Semver\Semver::satisfies() using the core_version_requirement
as input. This value will be entered by users whilst creating extension .info.yml files.
Proposed resolution
Catch the UnexpectedValueException as throw a more useful InfoParserException that points to the file where there is a problem.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
N/a
Comment | File | Size | Author |
---|---|---|---|
#13 | 3088081-13.patch | 2.41 KB | alexpott |
#13 | 11-13-interdiff.txt | 988 bytes | alexpott |
#11 | 3088081_9_11.interdiff.txt | 1 KB | dww |
#11 | 3088081-11.patch | 2.61 KB | dww |
#9 | 3088081-9.patch | 2.63 KB | alexpott |
Comments
Comment #2
alexpottComment #3
Wim LeersSince @tedbow was the lead on the
core_version_requirement
thing, I think it'd be great to get his thoughts on this.Comment #4
alexpottIf we don't do this you get an UnexpectedValueException with the message
Could not parse version constraint not: Invalid version string "not"
Which is not very helpful. InfoParserDynamic should catch all possible exceptions and re-throw them with helpful messages saying which key and value and which file.
Comment #5
xjmFWIW I think this improvement is solid, and more Gracie in tests is always a good thing. Tentative RTBC assuming tests pass, but I'll also ping Ted and make sure he doesn't have any concerns.
Comment #6
cilefen CreditAttribution: cilefen as a volunteer commentedComment #7
tedbowThis looks good! Thanks!
Comment #9
alexpottAh there was a test already... let's update that one.
Comment #10
dwwSuper duper small nit:
No need for
. $filename
since we're already using"
and including the value of{$parsed_info['core_version_requirement']}
directly in the string.Would be slightly faster and take less space in the code to do this:
Otherwise, huge +1 to making this more user-friendly. :)
Comment #11
dwwComment #12
tedbowThis line doesn't need the 2 calls to
parse()
. I think this left from when it was a its own test.The file
nonsense_core_version_requirement.info.txt
is not being created. The only reason the test passes is because if the fail does not exist and empty array is return and no exception is thrown.Comment #13
alexpottAddressing #12
Comment #14
dww🤦♂️I don't know how I saw #10 but completely overlooked #12. :(
:ashamed: ;)
Sorry,
-Derek
Comment #15
tedbow@dww it happens 😜
#10 was a good catch!
Looking good now!
Comment #18
catchCommitted/pushed to 9.0.x and 8.9.x, moving to 'to be ported' for when packaging is up and running again.
Comment #19
tedbow@catch thanks for committing, and thanks everyone for the work on this.
testing #13 on 8.8.x as it still applies
Comment #21
catchCherry-picked to 8.8.x, thanks!