Problem/Motivation
Follow-up to #3061411: Hide the daterange_duration widget if the right version of duration_field isn't installed:
If you have a git checkout of duration_field or use the 8.x-2.x-dev release, this code fails:
try {
$duration_field_info = \Drupal::service('extension.list.module')->getExtensionInfo('duration_field');
if (version_compare($duration_field_info['version'], '8.x-2.0-rc2', '<')) {
// If we don't have 8.x-2.0-rc2 or later, hide the widget.
unset($info['daterange_duration']);
}
}
catch (UnknownExtensionException $e) {
// Also hide the widget if there is no duration_field module at all.
unset($info['daterange_duration']);
}
version_compare() is confused with "8.x-2.x-dev", the code thinks we don't have a working version of duration_field, and we hide the plugin unnecessarily. This causes tests to fail if you're running in an environment with git checkouts.
Proposed resolution
Instead of trying to directly inspect version numbers, let's just make sure one of the methods we need from one of the duration_field service classes is_callable().
Remaining tasks
- Do it.
- Watch testbot still pass.
- Peer review?
- Commit.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3093327-2.patch | 1.16 KB | dww |
Comments
Comment #2
dwwThis works locally on 8.7.x and 8.8.x. Let's see that the bot agrees. It's not going to actually see much change, since our .info.yml has this:
Comment #3
dwwComment #4
rwilson0429 commentedThe patch seems to work for me. Prior to installing this patch, the 'Date and time range with duration widget' was not available on the manage form display. Thanks.
Comment #6
dwwThis has continued to be a problem for local testing via Git checkouts. Pushed to 8.x-1.x.
Comment #7
dwwp.s. Thanks for testing, @rwilson0429. Giving you credit here for that.