Problem/Motivation
When using the Recurring formatter on an event with per minute/per hour frequency, the following fatal exception is thrown.
Error: Call to a member function getValue() on array in Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter->viewElements() (line 286 of modules/contrib/smart_date/modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php).
This is because the $instances_nested variable returns a date-indexed array of instances, meaning all further calls making use of $instances will fail because it no longer contains a flat array of field instances.
Steps to reproduce
Enable recurring event frequency for the field by Minutes or Hourly.
While making use of the Recurring formatter.
Add a date which repeats every 3 minutes and ends after 2 times.
When you attempt to view it on the frontend, the page will throw a fatal exception.
Proposed resolution
I'm not exactly sure what the preferred approach is.
We could add appropriate error handling or potentially the $instances_nested variable if necessary.
Remaining tasks
Provide issue fork/patch
User interface changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | smart_date-3399865-minutely-hourly-fatal-exception-3.diff | 1.19 KB | codebymikey |
Issue fork smart_date-3399865
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
codebymikey commentedAttached an approach which ensures that the
$instancesarray is in a consistent state.Comment #5
mandclu commentedI decided to do a little more refactoring but I believe this is essentially the solution you provided. Thanks for identifying this, and for providing a fix.
Comment #6
mandclu commented