webform_civicrm
webform_civicrm copied to clipboard
D10 - Fatal error on empty group submission if configured as public group in settings
Overview
Fatal error on empty group submission if configured as public group in settings
Before
To replicate
- Create a webform with group = Public Group
- Submit the form as anonymous user without enabling any options for the group field.
- Error
Drupal\Core\Entity\EntityStorageException: 'public_groups' is not a valid option for field group_id in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
After
Fixed.
Technical Details
Unsetting $val works fine for logged-in or authorized users because it assigns it to $this->data only if the contact is logged in - https://github.com/colemanw/webform_civicrm/blob/6.x/src/WebformCivicrmPostProcess.php#L2579-L2583
For anonymous users, the key remains in $this->data
, leading to an error. Removing it immediately fixes the error.