Check if case type is active and if caseRoles exists before trying to fetch the roles

Created on 8 April 2023, about 1 year ago

1.0 Problem/Motivation

Whenever navigating to the CiviCRM tab on a webform (admin/structure/webform/manage/WEBFORMNAME/civicrm) I see this:

Warning: Undefined array key "caseRoles" in Drupal\webform_civicrm\Fields->wf_crm_get_fields() (line 576 of modules/contrib/webform_civicrm/src/Fields.php).
Drupal\webform_civicrm\Fields->wf_crm_get_fields('fields') (Line: 47)
Drupal\webform_civicrm\Fields->get('fields') (Line: 60)
Drupal\webform_civicrm\Utils->wf_crm_get_fields() (Line: 60)
Drupal\webform_civicrm\AdminForm->initialize(Array, Object, Object) (Line: 53)
Drupal\webform_civicrm\Form\WebformCiviCRMSettingsForm->buildForm(Array, Object)

Warning: foreach() argument must be of type array|object, null given in Drupal\webform_civicrm\Fields->wf_crm_get_fields() (line 576 of modules/contrib/webform_civicrm/src/Fields.php).
Drupal\webform_civicrm\Fields->wf_crm_get_fields('fields') (Line: 47)
Drupal\webform_civicrm\Fields->get('fields') (Line: 60)
Drupal\webform_civicrm\Utils->wf_crm_get_fields() (Line: 60)
Drupal\webform_civicrm\AdminForm->initialize(Array, Object, Object) (Line: 53)
Drupal\webform_civicrm\Form\WebformCiviCRMSettingsForm->buildForm(Array, Object)

2.0 Detailed steps to reproduce (embed screenshots)

This happens when a case type is disabled and has no definition. And thus it doesn't have roles defined either.

3.0 Proposed resolution

The best thing to do here maybe is to both check if a case type is enabled and also if the array key exists.

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada nubeli

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

Comments & Activities

Production build 0.69.0 2024