Error: Call to a member function setData() on null in Drupal\webform_civicrm\WebformCivicrmPostProcess->submissionValue() (line 2723)

Created on 4 April 2023, about 1 year ago
Updated 29 July 2023, 11 months ago

Getting a fatal error: Error: Call to a member function setData() on null in Drupal\webform_civicrm\WebformCivicrmPostProcess->submissionValue() (line 2723 of /app/httpdocs/modules/contrib/webform_civicrm/src/WebformCivicrmPostProcess.php).

In WebformCiviCRMPostProcess:submissionValue() line 2721 it attempts to set data using

$webform_submission->setData($data);

It shouldn't assume $webform_submission is ready because it's only being set conditionally above if the form_state is not empty. See:

    if (!empty($this->form_state)) {
      $form_object = $this->form_state->getFormObject();
      /** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
      $webform_submission = $form_object->getEntity();
      $data = $webform_submission->getData();
    }
    else {
      $data = $this->submission->getData();
    }

So I think it should be checking again if form_state is not empty since that's the only time $webform_submission is set:

    if ($value !== NULL && !empty($this->form_state)) {
      $data[$fid] = $value;
      $webform_submission->setData($data);
      return $value;
    }

Background:

I'm running webform_migrate module to migrate webform submissions. I was actually hoping that the migration wouldn't trigger all this processing in CiviCRM, but since it is, we should make sure it's not buggy I figure.

🐛 Bug report
Status

Fixed

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