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.

Comments

TwoD created an issue. See original summary.

twod’s picture

Status: Active » Needs review
StatusFileSize
new2.66 KB

Something like this patch should do it. :)

afagioli’s picture

Hi TwoD,
added today to dev 8.x-3.x
Thanks!

afagioli’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dtarc’s picture

StatusFileSize
new958 bytes

I'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.

dtarc’s picture

Version: 8.x-1.x-dev » 8.x-3.x-dev
afagioli’s picture

Thanks dtarc,
will work on this

afagioli’s picture

Status: Closed (fixed) » Needs work
afagioli’s picture

Version: 8.x-3.x-dev » 8.x-10.x-dev

  • afagioli committed 5edd1ccf on 8.x-10.x
    #3125109 #3368663 #3368645 bat_group, DrupalCS
    
afagioli’s picture

Status: Needs work » Needs review
afagioli’s picture

Status: Needs review » Closed (outdated)