After upgrade webform 3.11 security update, I got this error.

warning: Invalid argument supplied for foreach() in /sites/all/modules/mimemail/mimemail.inc on line 359.
warning: Cannot use a scalar value as an array in /sites/all/modules/webform/includes/webform.submissions.inc on line 269.
warning: Invalid argument supplied for foreach() in /sites/all/modules/mimemail/mimemail.inc on line 359.

to create this error

1. fill in a webform
2. submit it
3. error display in confirmation page.

So I downgrade the security webform update now.

Comments

sgabe’s picture

Title: error after upgrade webform » Mime Mail error after upgrade Webform
Project: Mime Mail » Webform
Version: 6.x-1.0-alpha8 » 6.x-3.11
Category: support » bug

So this is a Webform issue.

weseze’s picture

I can not reproduce this...

luti’s picture

Same here. Mime Mail 6.x-1.0-alpha8, Webform 6.x-3.11, "Include files as attachments" setting not checked (unselected).

Error message:

warning: Invalid argument supplied for foreach() in .../modules/mimemail/mimemail.inc on line 368.

which is:

  foreach ($attachments as $a) {

within mimemail_html_body() function ($attachments shall be an array).

Doesn't look nice, but a message still arrives as expected.

luti’s picture

StatusFileSize
new895 bytes

Heh,

we set (line 269):

$message['attachments'] = $attachments;

but immediately in next line (line 272), we set $message array (loosing $message['attachments']):

$message = drupal_mail(...);

I've switched those 2 lines, and it seems to be OK now (a patch is attached).

quicksketch’s picture

Oh hmm, that's not very smart. The intention was to allow #1087796: Allow altering of attachments in hook_mail_alter(). I think this means that we need to keep the line where it is, but it should be assigned to $mail_params, not to $messages.

ceege111’s picture

#4 Switching these 2 lines worked for me. Not sure about the implications. Using mime mail.

luti’s picture

I have the attachment option unchecked, so don't care very much about the details (implications) at the moment. I've just had to remove the unpleasant error message for my production site, and as I've seen I am loosing the variable through this call, I am setting it after...

By the way, what should hook_mail_alter() do with the attachments? If I attach a file, I normally don't want it to be renamed (or even the content to be changed anyhow)...

esbon’s picture

#6 I am on the same boat. Hopefully we will have a final solution soon!

Brainwrap’s picture

Yep, I'm having the same issue; here's the full error code that comes up every time I submit a form (the submission goes through fine, but the warning code appears):

warning: Invalid argument supplied for foreach() in .../all/modules/mimemail/mimemail.inc on line 359.
warning: Cannot use a scalar value as an array in .../sites/all/modules/webform/includes/webform.submissions.inc on line 269.
warning: Invalid argument supplied for foreach() in .../sites/all/modules/mimemail/mimemail.inc on line 359.
warning: Cannot use a scalar value as an array in .../sites/all/modules/webform/includes/webform.submissions.inc on line 269.
warning: Invalid argument supplied for foreach() in .../sites/all/modules/mimemail/mimemail.inc on line 359.

Note: I just tried swapping lines 269 & 272 (per #4 above) webform.submissions.inc and can confirm that it seems to have fixed the issue (well, the errors went away, anyway).

cesar.brod@gmail.com’s picture

Same here... Applied the line switch suggested by #4

Rainman’s picture

another here, same results errors go away after switching the suggested lines.

an additional error came up with the upgrade from 6.2 due to previous use of header theming for HTML email found here: http://drupal.org/node/270472

creeksideplayers’s picture

I'm seeing the same error with line 269, and I applied the line switch suggested by #4, and it worked for me.

Balbo’s picture

Same here.
Switch as in #4 applied.

roderik’s picture

Status: Active » Needs review
StatusFileSize
new584 bytes

@quicksketch / #5: ah, that figures.

(Indeed, that's consistent with #1087796-6: Allow altering of attachments in hook_mail_alter(). This got rid of the error; I didn't test attachments though. #1087796 has already done that anyway.)

luti’s picture

@roderik,

I've applied your patch, but still get the same message as above (invalid argument supplied...). As said, with no attachment and attachment option unchecked. Have you tested your patch, or just made it (according to #5)? ;-)

brei9000’s picture

@roderik,

Patch did not work for me either.

roderik’s picture

StatusFileSize
new1.31 KB

I tested... and got rid of the error I saw, which was only the "Cannot use a scalar value as an array" leading me to this issue.

I didn't get the other error because I was still on mimemail 6.x-1.0-alpha6. Now, on mimemail 6.x-1.0-alpha8, I get the other "Invalid argument supplied for foreach()".

Here's a new one.
It seems that $message['attachments'] is incorrect; the attachments do not live there and never have. $mail_params is returned as $message['params'].

mmariott’s picture

After upgrading from webform 6.x-3.9 to webform 6.x-3.11, I got the same error reported at the beginning of this thread:

warning: Invalid argument supplied for foreach() in /sites/all/modules/mimemail/mimemail.inc on line 359.
warning: Cannot use a scalar value as an array in /sites/all/modules/webform/includes/webform.submissions.inc on line 269.
warning: Invalid argument supplied for foreach() in /sites/all/modules/mimemail/mimemail.inc on line 359.

I just replaced the newer modules/webform/includes/webform.submissions.inc (6.x-3.11)
with the older modules/webform/includes/webform.submissions.inc (6.x-3.9)
and the error disappeared.

So for the future release of webform the old version of this file could be kept, just applying "security related" changes

quicksketch’s picture

So for the future release of webform the old version of this file could be kept, just applying "security related" changes

Yikes! I would NOT recommend keeping some files from Webform but not others. If you want just the security related changes, use the 3.10 version (since that's exactly what it is, 3.9 with nothing but security fixes).

star-szr’s picture

Subscribe

luti’s picture

Seems to work now, at least with my settings (no errors displayed). Thanks.

demma10’s picture

I applied the patch in comment #17 and it removes both errors. Thanks for the patch.

I haven't tested with attachments as files ticked, none of my forms use that setting.

quicksketch’s picture

Status: Needs review » Fixed

#17 worked for me too. Tested it and it makes all the e-mails come through again with MIME Mail. I've committed this patch to the 6.x branch, D7 seems like it's working fine without these changes (which is probably why I didn't notice the first time). Thank roderik!

Brainwrap’s picture

It's great that the #17 patch works, but I used the swap-lines-269-and-272 solution for like a dozen sites...is there any reason I shouldn't just leave those as is for the time being?

roderik’s picture

@Brainwrap: the only reason for having to switch from your solution to the committed solution now, would be: #1087796: Allow altering of attachments in hook_mail_alter().
If you don't need to modify the attachments in some 'alter hook' you're fine for the moment.

(And you don't need to. If you needed to, you'd know.)

Brainwrap’s picture

Glad to hear it, thanks!

esbon’s picture

quicksketch thanks for all the work. Our sites would be useless without a way to send HTML emails

Saoirse1916’s picture

Ditto, I just applied the patch and it solved the problem on my end as well. Thanks!

virtuali1151’s picture

# 4 worked for me... should this be commited for future versions?

gregarios’s picture

Status: Fixed » Active

When can we expect a new version with these "fixed" patches implemented? Has it been implemented in a -dev version already?

gr33nman’s picture

#17 1162112-17.patch applied cleanly for me.
Thanks Roderik.

quicksketch’s picture

Status: Active » Fixed

"fixed" means it's been committed (as I said in #23). Yes it's already in dev releases. The fix will be in the 3.12 official version.

roderik’s picture

@quicksketch: maybe the confusion in #30 is heightened because of the absence of 'dev releases on the project page'?

Is this a 'policy decision' on your part? Or some remnant of the Git migration? (Sorry I have no clue where to look up the answer to this possibly general question.)

HTF’s picture

subscribing

hondaman900’s picture

Patch in comment #17 makes no difference for me. I still get the warning: Invalid argument supplied for foreach() in /home/....../modules/mimemail/mimemail.inc on line 359. error, with or without the file attachments checkbox checked.

This is very disconcerting for my users, to get this error after submitting the form. Any solutions yet?

Thanks in advance.

virtuali1151’s picture

@hondaman900 - did you try the solution in #4... try switching the lines around as stated. This worked for me. Not sure why this isnt commited.

Cheers.

chrisla’s picture

Patch in #17 worked for me. Thanks roderik and quicksketch for your attention to this.

I'm using Mime Mail 6.x-1.0-alpha8 and was only experiencing the 'warning: Cannot use a scalar value as an array in /sites/all/modules/webform/includes/webform.submissions.inc on line 269' issue

giorgosk’s picture

patch from #17 worked for me

will this be included in 3.12 release ?

the way this issue is marked as fixed is a bit confusing
since there is no release (dev or minor release that includes this)

easp’s picture

subscribing

lulyx’s picture

patch #17 worked for me too. Thanks roderik! good job

breeze76’s picture

OK.. I am getting this error and want to install the patch... I do not know how to do that... Could someone please direct me to the right place or explain how to do it...

Thanks...

giorgosk’s picture

@breeze76
learn how to apply patches http://drupal.org/patch/apply

or apply by hand
#17 is a very simple patch
3 line deletions (-) and 2 line additions (+)
starting on line 266
on function webform_submission_send_mail
on file sites/all/modules/webform/includes/webform.submissions.inc

bbruda’s picture

my warning
warning: Invalid argument supplied for foreach() in /sites/all/modules/mimemail/mimemail.inc on line 361.
patch #17 worked for me too. Thanks roderik!

breeze76’s picture

Just an FYI... Patch #17 worked for me as well... Thanks to GiorgosK for explaining how the patch works, even though I read the link on patching... I still do not get how to use the git to patch.. guess it will take some time for me to get there..

leosuaar’s picture

Thank you, #17 worked for me too, I am happy!

Status: Fixed » Closed (fixed)

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

gorka’s picture

Hi Hondaman900,
did you finally fix it? I'm getting the same error and I cannot get rid of it...

Mime Mail 6.x-1.x-dev (2011-Oct-15 )
Webform 6.x-3.14
Drupal core 6.22
PHP Version 5.3.3-7+squeeze1
MySQL 5.1.49

Regards,
Gorka