This has shown up after I have selected an options list in Component value selectbox in E-mail settings and pressed Add.

Notice: Uninitialized string offset: 0 in webform_email_edit_form() (Zeile 267 von sites/all/modules/webform/includes/webform.emails.inc).

#default_value is line 267:

        foreach ($options as $key => $label) {
          $form[$field . '_mapping'][$cid][$key] = array(
            '#type' => 'textfield',
            '#title' => $label,
            '#default_value' => is_numeric($email[$field]) && $email[$field] == $cid && isset($email['extra'][$field . '_mapping'][$key]) ? $email['extra'][$field . '_mapping'][$key] : '',
            '#attributes' => array('placeholder' => t('email@example.com')),
          );
        }

Comments

quicksketch’s picture

Thanks, this issue may be related to #2028949: Warning: Invalid argument supplied for foreach() in webform_submission_send_mail(). I'll see if I can reproduce the problem.

hass’s picture

I tried to reproduce it again one minute later, but failed. I cannot remember what I've done in what order. I haven't had the patch from #2038139: Uninitialized string offset: 0 in webform_email_edit_form() applied.

quicksketch’s picture

Status: Active » Postponed (maintainer needs more info)

Hm, I can't reproduce it either. Let me know if you can figure out way to reproduce this error.

quicksketch’s picture

Issue summary: View changes

Updated issue summary.

marcoscano’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Also happened for me, but only the first time the form was built.
Version 7.x-4.0-beta1, core 7.23
- Created a select element in the form, with different pairs "key|label"
- When was going to create the email mapping using the element created previously, the notices appeared - one for each pair key|label, but all of them with the same message:
Notice: Uninitialized string offset: 0 in webform_email_edit_form() (line 267 of /var/www/html/sites/all/modules/webform/includes/webform.emails.inc).

The mapping values are stored correctly, and the following builds of the form are executed correctly, i.e. the notices are not shown.

Don't know if this information helps to investigate the issue further, marking it as active just in case

Also marked #2134355: Error when setting an email address for a webform as duplicate of this one

marcoscano’s picture

Status: Active » Needs review
StatusFileSize
new910 bytes

It happened again with another form, so I didn't save it (to avoid loosing track of the bug) and could investigate it a bit further. Apparently the problem comes from

isset($email['extra'][$field . '_mapping'][$key])

once the $email['extra'] is an empty string at that point and the [] is evaluated before the isset().

Added an additional is_array() to check that before the array evaluation. With this, for me the notices are gone.

Patch attached

quicksketch’s picture

Status: Needs review » Fixed

Thanks, works for me! Committed to 7.x-4.x branch.

fenstrat’s picture

Committed to 8.x-4.x in b68645a. Thanks.

ParisLiakos’s picture

ParisLiakos’s picture

Priority: Normal » Critical
Status: Fixed » Reviewed & tested by the community
StatusFileSize
new681 bytes

patch

fenstrat’s picture

Priority: Critical » Normal
Status: Reviewed & tested by the community » Fixed
StatusFileSize
new2.42 KB

Good catch @ParisLiakos. Rolled back in 831de1f.

I also noticed a change in webform.module specifically http://drupalcode.org/project/webform.git/blobdiff/4fca7450413989ceba73a... which came from http://drupalcode.org/project/webform.git/commit/b10ffeb so I also rolled that back (couldn't for the life of me figure out where it came from).

This doesn't apply to 8.x-4.x as it never had the accidental commit.

ParisLiakos’s picture

yeap, in 8.x-4.x it was committed correctly. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.