Problem/Motivation
After upgrade to 8.x-1.6 if I don't have the option selected to show the time this error is produced
TypeError: Drupal\date_ap_style\ApStyleDateFormatter::formatRange(): Return value must be of type string, null returned in Drupal\date_ap_style\ApStyleDateFormatter->formatRange() (line 293 of modules/contrib/date_ap_style/src/ApStyleDateFormatter.php).
Steps to reproduce
Have a date/time range field configured fill in data and have the formatter set to only show the date and not the time
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | TypeError-in-formatRange-3387650.patch | 3.05 KB | shelane |
| #5 | TypeError-in-formatRange-3387650-5.patch | 1.35 KB | emerham |
Comments
Comment #2
shelaneThanks for reporting this. I was able to replicate it with another case as all of these methods were given an updated signature with typing. In my case of a date that is not a date range date, this fix worked.
Can you test this patch?
Comment #3
shelaneComment #4
emerham commentedStill getting the same error in the function formatRange.
I think there's an issue in the formatRange, intellephese is saying that $output on line 293 is "probably undefined". Checking the logic it looks like if I don't have the option of "Show time" checked that $output will never be set and thus is null and being returned as such
Comment #5
emerham commentedI moved the if (isset($options['display_time']) && $options['display_time']) down 4 lines and added a new else statement to ensure that $output will have a value.
did some testing both showing and not showing the time date time range that is both same day and different days at different times.
Comment #7
kmonahan commentedWas just in the process of making a patch with the same change. :) Can confirm that #5 fixes the issue for me.
Comment #8
shelaneYep. That's it. Thank you very much!