webform_civicrm icon indicating copy to clipboard operation
webform_civicrm copied to clipboard

D10 - Fatal error on empty group submission if configured as public group in settings

Open jitendrapurohit opened this issue 10 months ago • 0 comments

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.

jitendrapurohit avatar Apr 23 '24 04:04 jitendrapurohit