Problem/Motivation
The background call to bat_api/calendar-events fails with an error if one has added a new state field to a Type Bundle and set it to be one of the Event fields on that Type Bundle, but not yet filled set a value into that field for any existing Types of that bundle.
The [static] state fields are usually set to required on the Type Bundles so I can see why the code assumes it should be possible to fetch a value from there and directly call bat_event_load_state() on it, but that function returns FALSE with the error below if there's no value yet.
Error: Call to a member function getCalendarLabel() on null in Drupal\bat_fullcalendar\FullCalendarFixedStateEventFormatter->format() (line 93 of /app/modules/contrib/bat/modules/bat_fullcalendar/src/FullCalendarFixedStateEventFormatter.php).
Proposed resolution
Guard any usage of the return value of bat_event_load_state() by wrapping them in if-statements.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | bat-missing_states-3125109-7.patch | 958 bytes | dtarc |
| #2 | 3125109.missing_states.patch | 2.66 KB | twod |
Comments
Comment #2
twodSomething like this patch should do it. :)
Comment #3
afagioliHi TwoD,
added today to dev 8.x-3.x
Thanks!
Comment #5
afagioliComment #7
dtarc commentedI'm re-opening this issue because the fix has caused bat events showing on full calendar to lose their color.
The problem with the fix is that when the bat event is loaded, if it has a calendar label then `$state_info` is never refreshed from the loaded event.
Here's a small patch that fixes this by making sure `bat_event_load_state()` is called again with the loaded bat event.
Comment #8
dtarc commentedComment #9
afagioliThanks dtarc,
will work on this
Comment #10
afagioliComment #11
afagioliComment #13
afagioliFixed in https://www.drupal.org/project/bat/releases/8.x-10.1-beta1
Thanks!
Comment #14
afagioli