Posted by anavarre on March 14, 2011 at 10:07am
5 followers
| Project: | Webform |
| Version: | 7.x-3.9 |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi,
I've got this Notice with Webform 7.x-3.9 on a fresh D7 install :
Notice : Undefined index: p2 in webform_component_list() (line 880 in /drupal/sites/all/modules/webform/includes/webform.components.inc).
The thing is I cannot tell exactly how it occurred. I know that I had it while creating a new Select options row as well as cloning one...but I also had several Selects options rows without any Notice message !
Weird isn't it ?
BTW, I saw @Network reporting this issue in #992220: Notice: Undefined variable: cid in webform_component_list() when trying to add a field. Here's the dedicated issue.
Comments
#1
I have experienced the same problem. To reproduce, create a webform with at least two pagebreaks (3 pages) and one or more components of type textfield or select on each page. The error will occur going to/coming from the edit screen of components placed on page 3 and beyond.
webform_component_list() is used in this moment to populate the "component" pull-down under "Conditional Rules" at the bottom of the edit page. The function is fed a list of components up until the last pagebreak, thus no errors until page 3. (The function is fine when it gets only page 1 components.)
webform_component_list() populates an array named $options, which contains cid(component id)=>label pairs for page 1 components, but also an array named "p2" of page 2 components, an array named "p3"... Line 880 takes the last of these and assumes the key portion is the cid of a web component. In some cases, however, it is "p2" or "p3". Since there is no component with an id of "p2", a notice is returned.
#2
Can recreate using the following:
-Clean minimal Drupal 7 instal
-Enable Webform
-Create new webform
-Create textfield
-Create pagebreak
-Create select
-Create pagebreak
Error then appears.
#3
Thanks guys. I couldn't make any sense of that segment of code and (it turns out) it wasn't doing anything anyway because it was supposed to be doing a comparison between $cid and $previous_cid, but $previous_cid was never getting incremented (it was always 0). Considering I couldn't figure out even why I put this code in here and it's not doing anything now, I've just removed the whole offending code block.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.