explode(): Passing null to parameter #2 ($string) of type string is deprecated in wf_crm_aval()

Created on 20 June 2025, 4 months ago

1.0 Problem/Motivation

In a Drupal 10 and CiviCRM system, the webforms throw the following warnings upon submission:

Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in wf_crm_aval() (line 498 of xxxx/dev/web/modules/contrib/webform_civicrm/webform_civicrm.module)

and

Undefined array key "#form_key" in Drupal\webform_civicrm\Utils->wf_crm_enabled_fields() (line 489 of xxxx/dev/web/modules/contrib/webform_civicrm/src/Utils.php)

2.0 Detailed steps to reproduce (embed screenshots)

Create a webform in Drupal 10.4.7 that includes CiviCRM fields with checkboxes, and make a test submission. Check the error protocol.

3.0 Proposed resolution

In the function wf_crm_aval of the file webform_civicrm.module, substitute the line
foreach (explode(':', $keys) as $key)
by the line
foreach (explode(':', $keys ?? '') as $key).

And in the function wf_crm_enabled_fields of the file Utils.php, substitute the line
$enabled[$key] = wf_crm_aval($submission, $c['#form_key'], NULL, TRUE);
by :

if(isset($c['#form_key'])) {
                    $enabled[$key] = wf_crm_aval($submission, $c['#form_key'], NULL, TRUE);
                }
🐛 Bug report
Status

Active

Version

6.3

Component

Code

Created by

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

Comments & Activities

  • Issue created by @uenu9
  • 🇨🇦Canada karing 🇨🇦

    From one of my team:

    "With a basic test I can not reproduce what they're reporting. I tried first on webform-civicrm.io but it's 10.3 and they say 10.4, but I didn't see it there either. Locally I'm using 10.4.7 (same as their report), 6.3.1 (same as their report), and webform parent 6.2.9 (they don't say, but that's the latest). I have a checkbox civicrm custom field for contacts, and it's on the form with "multiple" checked, along with existing contact / first name / last name. I used an incognito window, filled out all the fields and picked one of the checkbox options. Nothing in drupal watchdog or civi log or on screen. Also tried logged in as admin."

  • 🇬🇧United Kingdom kenorb

    Same error, which happens at /webform/%/test (using 6.2.3), here is a stack trace:

    25/Jun 13:14    php     Debug   Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in wf_crm_aval() (line 503 of /var/www/html/web/modules/contrib/webform_civicrm/webform_civicrm.module) #0 /var/www/html/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'explode(): Pass...', '/var/www/html/w...', 503)
    #1 [internal function]: _drupal_error_handler(8192, 'explode(): Pass...', '/var/www/html/w...', 503)
    #2 /var/www/html/web/modules/contrib/webform_civicrm/webform_civicrm.module(503): explode(':', NULL)
    #3 /var/www/html/web/modules/contrib/webform_civicrm/src/Utils.php(484): wf_crm_aval(Array, NULL, NULL, true)
    #4 /var/www/html/web/modules/contrib/webform_civicrm/src/WebformCivicrmPostProcess.php(105): Drupal\webform_civicrm\Utils->wf_crm_enabled_fields(Object(Drupal\webform\Entity\Webform), Array)
    #5 /var/www/html/web/modules/contrib/webform_civicrm/src/Plugin/WebformHandler/CivicrmWebformHandler.php(135): Drupal\webform_civicrm\WebformCivicrmPostProcess->validate(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\webform\Entity\WebformSubmission))
    #6 /var/www/html/web/modules/contrib/webform/src/Entity/Webform.php(2765): Drupal\webform_civicrm\Plugin\WebformHandler\CivicrmWebformHandler->validateForm(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\webform\Entity\WebformSubmission))
    #7 /var/www/html/web/modules/contrib/webform/src/WebformSubmissionForm.php(1887): Drupal\webform\Entity\Webform->invokeHandlers('validateForm', Array, Object(Drupal\Core\Form\FormState), Object(Drupal\webform\Entity\WebformSubmission))
    #8 [internal function]: Drupal\webform\WebformSubmissionForm->validateForm(Array, Object(Drupal\Core\Form\FormState))
    #9 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
    #10 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(275): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
    #11 /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'webform_submiss...')
    #12 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('webform_submiss...', Array, Object(Drupal\Core\Form\FormState))
    #13 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('webform_submiss...', Array, Object(Drupal\Core\Form\FormState))
    #14 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\webform\WebformSubmissionForm), Object(Drupal\Core\Form\FormState))
    #15 /var/www/html/web/modules/contrib/webform/src/Entity/Webform.php(1257): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\webform\Entity\WebformSubmission), 'test')
    #16 /var/www/html/web/modules/contrib/webform/src/Controller/WebformTestController.php(128): Drupal\webform\Entity\Webform->getSubmissionForm(Array, 'test')
    #17 [internal function]: Drupal\webform\Controller\WebformTestController->testForm(Object(Symfony\Component\HttpFoundation\Request))
Production build 0.71.5 2024