2

When creating (or saving) a custom data group or (field)set the following error pops up:

Notice: Undefined offset: 0 in webform_civicrm_civicrm_postSave_civicrm_custom_group() (line 436 of /home/unidosnow/www/www/sites/all/modules/webform_civicrm/webform_civicrm.module)

The code throwing this:

/**
 * Implements hook_civicrm_postSave_tableName().
 *
 * Handles adding/editing a custom group.
 *
 * @param CRM_Core_DAO_CustomGroup $dao
 */
function webform_civicrm_civicrm_postSave_civicrm_custom_group($dao) {
  module_load_include('inc', 'webform', 'includes/webform.components');

  // get all fieldsets with custom group ID
  $customGroupId = $dao->id;
  $dbResource = db_query("SELECT * FROM {webform_component} WHERE type ='fieldset' "
          . "AND form_key LIKE '%cg{$customGroupId}_fieldset'");
  $fieldsets = $dbResource->fetchAll(PDO::FETCH_ASSOC);

  // check if dao fields have been fetched
  if (!$dao->title) {
    $dao->find(TRUE);
  }

  // run only if the title of the custom group has changed in civicrm
  -->>  if ($fieldsets[0]['name'] != $dao->title) {  <<-- Exception here
    foreach ($fieldsets as $field_info) {
      $component = array();
      $component['name'] = $dao->title;
      $component['type'] = $field_info['type'];
      $component['form_key'] = $field_info['form_key'];
      $component['weight'] = $field_info['weight'];
      $component['nid'] = $field_info['nid'];
      $component['cid'] = $field_info['cid'];
      $component['pid'] = $field_info['pid'];
      webform_component_update($component);
    }
  }
}

The custom set creates successfully, haven't yet tried to use it in a webform. Before the 4/25 update I had created custom data sets without this error. Don't have record of the versions I was using at the time, the current versions that show the problem are CiviCRM 4.7.29, Drupal Core 7.59, webform-civicrm 4.20, and webform 4.17.

2
  • Is the webform functional working? Does it update/insert the data you want? If so I would say it is a notice and ignore it. If it doesn't work the notice might be a clue in finding the cause but not neccesarly be the cause. Commented May 22, 2018 at 8:00
  • 1
    Finally had a chance to test. Despite the Notices, the custom CiviCRM fields are exposed and processed correctly by Webform. I'll ignore the Notices.
    – wil_SRQ
    Commented May 22, 2018 at 14:43

1 Answer 1

2

This was not a bug that caused any loss of functionality, just a php notice which has since been fixed via this patch: https://github.com/colemanw/webform_civicrm/pull/139

2
  • would you mind double-checking? DRU-2966760 was about a different PHP notice. And thanks for patching that!
    – wil_SRQ
    Commented Jun 4, 2018 at 7:01
  • 1
    I think the pr got linked to the wrong issue but if you look at the code you'll see it fixed the line you pointed to in your question.
    – Coleman
    Commented Jun 4, 2018 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.