I just started seeing this notice in my watchdog log after upgrading from 7.x-4.0-beta1 to 7.x-4.0-beta2:

Notice: Undefined index: #title in webform_expand_select_ids() (line 492 of /home/public_html/sites/all/modules/webform/components/select.inc).

This happens when both anonymous and logged-in users display an existing form that contains a number of checkbox elements.

CommentFileSizeAuthor
#10 webform-2195305-10.patch559 bytessah62
#5 debug-pic1.png7.34 KBsah62

Comments

sah62’s picture

Issue summary: View changes
sah62’s picture

Version: 7.x-4.0-beta2 » 7.x-4.0-beta3

The issue still exists in beta3.

quicksketch’s picture

Thanks, do you know if this is an issue specifically with Select or Other? On a normal form, I'm not seeing this error. My guess is that the "other" textfield may not have a #title attribute.

sah62’s picture

I'm not using Select (or other). Is there something else I can look at to better describe my form? I have Devel installed and can add some debugging code if it helps.

sah62’s picture

StatusFileSize
new7.34 KB

I've done a little debugging to see what's happening when attempts to reference $element[$key]['#title'] produce an "Undefined index" notice. In each case the iteration of the foreach loop is attempting to process a multicolumncheckboxesradios-table-open element that is itself an array of elements, none of which is "#title". I've attached a screen shot that shows one sample value of $element[$key].

The issue here is in the way the Multi-column checkboxes radios module constructs these elements. It doesn't include a title, which means that we can safely not worry about it containing scripts or CSS. One way to fix this would be to check if $element[$key]['#title'] is set before attempting to reference it. That is, change this:

$element[$key]['#title'] = webform_filter_xss($element[$key]['#title']);

to this:

if (isset($element[$key]['#title'])) {
    $element[$key]['#title'] = webform_filter_xss($element[$key]['#title']);
}

Does this look reasonable?

sah62’s picture

Hmm, I have a short memory :). I just did some digging through the issues queue for the Multi-column checkboxes radios module and found an issue (#1600540: Undefined index: #title in webform_expand_select_ids()) that I submitted in May 2012 that includes a patch to add the #title elements. It apparently still hasn't been committed.

sah62’s picture

Version: 7.x-4.0-beta3 » 7.x-4.0-rc1

This issue still exists in 7.x-4.0-rc1. Please see above for a suggested fix.

quicksketch’s picture

Status: Active » Needs review

Thanks @sah62! Let's make this "needs review" even though there isn't a patch yet, there's a suggestion on how to fix this.

danchadwick’s picture

Might be safer to use the form:

$x = isset($x) ? f($x) : '';

or

$x = f(isset($x) ? $x : '');

That way any subsequent code that relies on $x being defined won't throw an warning.

sah62’s picture

StatusFileSize
new559 bytes

Patch attached with @DanChadwick's suggestion incorporated.

Status: Needs review » Needs work

The last submitted patch, 10: webform-2195305-10.patch, failed testing.

quicksketch’s picture

Status: Needs work » Needs review

Hmm, I may have broken tests. The failure to even install is clearly not this patch's fault.

sah62’s picture

Version: 7.x-4.0-rc1 » 7.x-4.0-rc3

This issue still exists in 7.x-4.0-rc3.

sah62’s picture

10: webform-2195305-10.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 10: webform-2195305-10.patch, failed testing.

  • Commit 6b76112 on 7.x-4.x by quicksketch:
    Issue #2195305 by sah62: Notice: Undefined index: #title in...
quicksketch’s picture

Status: Needs work » Fixed

Thanks @sah62. I've committed this to 7.x-4.x. The test failures are driving me crazy. I'm trying to figure out their cause in #2244979: Figure out why testbot is failing all patches.

fenstrat’s picture

Version: 7.x-4.0-rc3 » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Fixed » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.0-rc3
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed 6b76112 to 8.x-4.x. Thanks!

  • Commit 0301e67 on 8.x-4.x authored by sah62, committed by fenstrat:
    Issue #2195305 by sah62: Notice: Undefined index: #title in...
sah62’s picture

Thank you!

Status: Fixed » Closed (fixed)

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