I am getting the following (repeating) errors (noticed in version 6.x-3.3 already):
warning: array_slice() [function.array-slice]: The first argument should be an array in .../webform/webform.module on line 2407.
warning: implode() [function.implode]: Bad arguments. in .../webform/webform.module on line 2407.
I don't know the reason (empty fields, or something from the past...), but in any case these errors are generated when $element['#parents'] in theme_webform_element_wrapper() doesn't exist (is empty).
I've temporary resolved this issue adding is_array() check (shouldn't hurt being there in any case); instead of:
$parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));
my line 2407 looks like this now:
$parents = str_replace('_', '-', implode('--', array_slice(is_array($element['#parents']) ? $element['#parents'] : (array) $element['#parents'], 1)));
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | webform_mime_mail_warning.patch | 1.12 KB | quicksketch |
Comments
Comment #1
quicksketchWeird, I wonder what elements don't have any #parents. All form elements should, otherwise they wouldn't have a "name" attribute either (since "name" is generated from #parents). Could you try to figure out which element doesn't have parents? It may be caused by another module (or your theme) modifying the form.
Comment #2
calbert commentedI am getting this error
* warning: array_slice() [function.array-slice]: The first argument should be an array in /var/www/vhosts/metrosource/drupal-6.16/htdocs/sites/all/modules/webform/webform.module on line 2407.
* warning: implode() [function.implode]: Bad arguments. in /var/www/vhosts/metrosource/drupal-6.16/htdocs/sites/all/modules/webform/webform.module on line 2407.
Comment #3
luti commentedIt's weird. When I display the form, all elements do have a #parent value.
When I submit the form, it seems to be processed twice. First, in more or less reverse order (last field on the form is processed first, but the rest is not exactly reverse - maybe as last time edited or so?), and all fields do not have a #parent here. After, fields seems to be processed in weight order (as displayed), and they do have a #parent here.
The majority of values seems to be the same both times. Some values:
- element['#id'],
- element['#parents'],
- element['#webform_validated'],
- element['#validated']
seems to be initialized later (present only in second processing).
Does it help?
BTW - the errors reported in #2 are exactly the same as mine, but in my case (11 form elements) everything is repeated 11 times after the form is submitted (message displayed on the confirmation page).
Comment #4
BBaptiste commentedHi.
I've the same error.
I use Drupal 6.19 + Webform 6.x-3.4 + Mime Mail 6.x-1.0-alpha6.
When I tick the webform parameter Email "Format: HTML" the error occurs, but if tick webform parameter Email "Format: Plain Text" I've no error.
I think this error may be caused by Mime Mail module ?
Have a good day !
Comment #5
Jerome F commentedHi, same error here.
I use the same module versions.
Comment #6
quicksketchHm, so a lot of people are having the problem. Can anyone describe how to reproduce this from a fresh install? I also have MIME Mail installed (though the dev version, not alpha6) and I'm not seeing these errors.
Comment #7
luti commentedHave you tried to send webform messages as HTML (so they go through MIMEmail)? It might be that something is processed twice, as such mails do have a plain text and an HTML part...?
In any case, my patch from initial post seems to resolve the problem for me, so for the moment I don't care much about how it comes to the first form processing (it is the first time that values are not initialized, and second time there are values properly set...).
Comment #8
sigol commentedAgree - getting the same error.
However, switch off HTML submission and it works perfectly.
Comment #9
sigol commented... sorry, pressed "Save" too early on my last post!
Can also confirm that your patch works perfectly. Thanks so much for this.
Comment #10
mellenger commentedThis patch just worked for me too. I have Mime Mail installed and am using HTML to send the webform email. Webform worked fine before i switched to HTML.
Comment #11
sgabe commentedSame issue here, after updating to 3.4 release. LUTi's patch works, though would be better to know what is causing this.
Comment #12
luti commentedAgree 100%.
But, for the moment, it is the most important for me that I am not getting a bunch of those errors all the time. I've tried to see how it comes to that, but I simply don't know enough about that all, unfortunately. Probably the authors (maintainers) should know more, how (when) this function can be triggered...
Comment #13
RedTop commentedSame issue here, Drupal 6.19, webform 3.4, Mime Mail 6.x-1.0-alpha6.
Comment #14
bomarmonk commentedYes, same issue here. Subscribing.
Comment #15
Nexus commentedI have the same issue. Using Drupal 6.17, webform 3.4, Mime Mail 6.x-1.0-alpha6. It gives me the following:
Comment #16
bomarmonk commentedI tried Luti's fix at the top of the thread and it seemed to work.
Comment #17
inductor commentedThe same issue, webform + mimemail. Subscribing.
Comment #18
Nexus commentedThere is no such line
$parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));in webform.module. Where did you find it ?
Comment #19
bomarmonk commentedI replaced line 2407, as indicated at the top of this thread. It definitely looked just like the line you have copied here, Nexus.
Comment #20
Nexus commentedI downloaded the last version of Webform and this is how my lines look like in webform.module:
I also searched for this line:
but it doesn't exist in the file.
Comment #21
bomarmonk commentedAre you using a development version?
Comment #22
Nexus commentedJust the recommended Release Version 6.x-3.4 Date 2010-Oct-20
Comment #23
vikramy commentedSubscribing..
Comment #24
luti commentedNexus,
in (my) version 3.4 (webform module, v 1.196.2.68 2010/10/18 07:38:44), these lines are starting at 2640. I'd suggest you to check again what do you have installed (line 2 of webform.module).
Comment #25
Nexus commentedHey LUTi, found it. The fix it's working fine, thanks !
Comment #26
mattcasey commentedThanks, LUTi—I have this issue too and glad someone posted a fix. I've tried to figure out what's going on but have nothing extra to offer. Using Drupal 6.19 MIME Mail 6.x-1.0-alpha6, Webform 6.x-3.4
Comment #27
torpy commentedSubscribing!
Comment #28
webdrips commentedSubscribe
Comment #29
webdrips commentedThe one detail I may add is this error may have been triggered by the form user entering a single quote in one of the fields. I essentially received a set of errors when a single quote is in one of the fields, but the submission works perfectly without the single quote.
I too am using Drupal 6.19, Webform 6.x-3.4, and MIME Mail 6.x-1.0-alpha6.
Comment #30
quicksketchThanks daneesia.
More than anything else, I need step-by-step instructions to reproduce the problem, so far I'm still not sure what's causing the problem.
Comment #31
anrikun commentedMy steps to reproduce the bug:
1. Install and enable Mime Mail 6.x-1.0-alpha6
2. Create a webform with a field
3. Add an "E-mail to" and check "Send e-mail as HTML"
4. Try to submit the webform
Comment #32
anrikun commentedtheme_webform_element_wrapperis then called twice for each element.The first time it is called, there is no
#parentskey.That's why it displays a warning.
Comment #33
TimelessDomain commentedJust has this error from the following settings:
Mimemail - checked - Use mime mail for all messages (Mime Mail 6.x-1.0-alpha6)
Webform - checked - Send e-mail as HTML (Webform 6.x-3.4)
fixed it by
Unchecking Webform Send e-mail as HTML
Comment #34
nonzod commentedSame problem
Drupal 6.19
Webform 6.x-3.4
MimeMail 6.x-1.0-alpha6
* warning: array_slice() [function.array-slice]: The first argument should be an array in /var/www/httpdocs/sites/all/modules/webform/webform.module on line 2407.
* warning: implode() [function.implode]: Bad arguments. in /var/www/httpdocs/sites/all/modules/webform/webform.module on line 2407.
I want to send HTML email.
Comment #35
sylvaticus commentedsubscribing!
Comment #36
quicksketchI've committed this patch which fixes the problem with the warnings. As it turns out, the warnings thrown by PHP have no actual effect on either the sending of e-mails or display unless your CSS targets individual items by ID.
Comment #37
anrikun commentedWouldn't it be better to simply skip the process when #parents is not set (the first time
theme_webform_element_wrapperis called)?Comment #38
quicksketch@anrikun: Not sure I follow you. The #parents array is still necessary to properly generate the class and ID of the component when sending the e-mail. This makes it so that CSS can target the element in the same way regardless of whether the component is being shown when viewing the submission on the website or when sending an HTML e-mail.
Comment #39
anrikun commentedI meant:
theme_webform_element_wrapperis called twice (see #3, #31, #32) after form submit.The warnings occur at first call, when #parents key is not defined yet.
But this first call has no use, it's the second one that is important.
So testing if #parents key exists and simply returning if not could do the trick, couldn't it?
Comment #40
quicksketchThe first time (when the warning occur) are when the %email[key] tokens are generated. If we didn't provide #parents for that call, then the %email[key] tokens would be missing the classes array.
Comment #41
anrikun commentedAll right, I had missed that point. Thanks for the info.
Comment #42
beyond67 commentedHas this been fixed in the latest 3.5 version?
Comment #43
quicksketchNo, the 3.5 version was an out-of-release security-only update, meaning it is exactly the 3.4 version with nothing but the security flaw corrected. I'm still planning on making new releases of the module with the next week (3.6 now) that will include the fix from this issue.