RRULE Field Mapping uses brittle logic

Created on 4 March 2024, 10 months ago

Problem/Motivation

IcalFieldsWizard::createDefaultEvent() contains this line of code:

        $rruleHelper = $entity->field_recur[0]->getHelper();

It would seem that "field_recur" in this case is a reference to a field that just happens to have the machine name "field_recur". Which is also presumes is a field provided by the Recurring Dates Field β†’ module.

I'm frankly very surprised that this hasn't come up sooner, but this would certainly break if anyone named the field something besides "field_recur", or mapped the recurring date field to some field that had a field type of something not provided by that module. Earlier in this section of code, it also explicitly looks at the body field:

      if ($this->fieldMapping['rrule_field'] == 'body') {
        $rrule = $entity->get('body')->getValue()[0]['value'];
        $event->addRecurrenceRule($rrule);
      }

Ideally, we just look at the field mapped to the rrule field, check that field's type, and use an appropriate handler to pass that recurring rule to the appropriate event constructor.

Note, this was noticed while we are upgrading the module to work with the 2.x version of Eluceo/ical. As of now, which VIews iCal uses to render it's output in icalendar format. As of this writing, that library does not support recurring rules in events. See #3209012: Move to eluceo/ical 2.0 β†’

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024