Unable to save configuration for webform handlers with conditionals support disabled

Created on 7 February 2023, about 2 years ago
Updated 14 February 2023, about 2 years ago

Problem/Motivation

After upgrading from 6.1.3 to 6.1.4, I'm unable to save webform handlers having conditionals disabled. This is introduced by the fix for issue #3274742 β†’ .

Steps to reproduce

1. Apply the diff attached to this issue ( webform_example.diff β†’ )
2. Enable the webform_example module
3. Navigate to the newly created webform
4. Edit the webform handler with the ID webform_no_conditions
5. Hit the Save button
6. You'll notice the handler will not be saved, if you check the browser console or Drupal watchdog logs, you'll notice there is an error:

TypeError: Argument 1 passed to Drupal\webform\Plugin\WebformHandlerBase::setConditions() must be of the type array, null given, called in /app/web/modules/contrib/webform/src/Form/WebformHandlerFormBase.php on line 315 in Drupal\webform\Plugin\WebformHandlerBase->setConditions() (line 264 of /app/web/modules/contrib/webform/src/Plugin/WebformHandlerBase.php).

Proposed resolution

Not 100% sure, but it might be as simple as changing line 315 in src/Form/WebformHandlerFormBase.php from

$this->webformHandler->setConditions($form_state->getValue('conditions'));

to

$this->webformHandler->setConditions($form_state->getValue('conditions', []));

or reverting the line to the code of 6.1.3

// Clear conditions if conditions or handler is disabled.
if (!$this->webformHandler->supportsConditions() || $this->webformHandler->isDisabled()) {
  $this->webformHandler->setConditions([]);
}
else {
  $this->webformHandler->setConditions($form_state->getValue('conditions'));
}
πŸ› Bug report
Status

Fixed

Version

6.1

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands sanderwind Friesland

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

Comments & Activities

Production build 0.71.5 2024