Using the 5.x-1.4 version of webform, the default email address, subject, and return address name are not used when a new web form is set to use default values. Instead nothing is used. If however, None is selected, the default values are used - huh? That's funny.

It turns out the problem is due to a misunderstanding of how strcmp works. The offending lines are on 1360, 1363, & 1366 of webform.module. Strcmp does not return true if the two values passed to it are equal as one might expect. Instead it returns:

  • < 1 if the first parameter is less then the 2nd
  • 0 if the first parameter equals the second
  • > 1 if the first parameter is greater than the second

Since in php 0 is false, this is exactly the wrong thing to do.

I do not believe there is any good reason to use strcmp for this comparison, the fix is the following.

Replace this code (currently lines 1360-1368):

      if (strcmp('none', $node->email_from_name)) {
        $email_from_name = '';
      }
      if (strcmp('none', $node->email_from_address)) {
        $email_from_address = '';
      }
      if (strcmp('none', $node->email_subject)) {
        $email_subject_string = '';
      }

with this:

      if ($node->email_from_name == 'none') {
        $email_from_name = '';
      }
      if ($node->email_from_address == 'none') {
        $email_from_address = '';
      }
      if ($node->email_subject == 'none') {
        $email_subject_string = '';
      }

It is a simple fix so I didn't roll a patch. I'm working on some other bugs and will include it in one big patch sometime soon.

Comments

scafmac’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.22 KB

Been testing this patch and it is ready to be committed.

jonathan_hunt’s picture

This fix worked for me. Applied by hand to webform.module,v 1.113.2.38 2007/06/13

scor’s picture

StatusFileSize
new1.18 KB

Already posted a patch 2 weeks ago : http://drupal.org/node/155915

Attached is the patch against the latest webform.module 1.113.2.42

scor’s picture

Priority: Normal » Critical

This issue has been reported again: no emails ([None] and [Default] Mail Settings are switched)
Set it to critical.

ashtonium’s picture

The two patches had an unrelated fix to an odd character in the opening comments, this chunk was failing but the relevant chunk containing the fix was applying cleanly, so I'll repost the patch with the unrelated comment correction removed.

ashtonium’s picture

StatusFileSize
new882 bytes

This is the version for those looking to patch this issue in their install of webform 5.x-1.4

ashtonium’s picture

Version: 5.x-1.4 » 5.x-1.x-dev
StatusFileSize
new858 bytes

and this is the edited version against the latest development snapshot.

- applied cleanly and fixed the issue

RTBC

scor’s picture

Version: 5.x-1.x-dev » 5.x-1.4

That's normal, the character is broken.... it should be AF
I didn't want to file an issue just for such a small typo.

scor’s picture

Version: 5.x-1.4 » 5.x-1.x-dev

oops... commented at the same time.
back to 1.x.dev

solutionsphp’s picture

Applied the patch listed above (http://drupal.org/node/152165#comment-276944), and it DID fix the problem with the blank subject in the resulting email, but it did NOT fix the problem with blank fields in the email.

I still see this in webform emails:

Submitted values are:
:

Drupal 5.2. I DO have the Location module enabled and noticed in this thread t(http://drupal.org/node/155743#comment-276563) hat one person had to make a change to it as well to get the webform email subject line working. I have the email subject line working fine though.

Any ideas?

jonathan_hunt’s picture

Missing form fields in email are another issue, see for example http://drupal.org/node/155743

mo6’s picture

The patch in #16 applies and fixes the issue. Please commit.

mo6’s picture

Oops, I meant #6 not #16.

neurojavi’s picture

Hi:

#6 works for me (version 5.x-1.4)

Many thanks.-

David Lesieur’s picture

Patch #6 works here too.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Applied. Thanks so much for the exhaustive confirmations. Makes maintenance so much easier. Thanks scor for the patch!

fuquam’s picture

Applied the patch. Still doesn't work. is the subject. The From address is my web server user name followed by the webserver name .com the in parenthesis (sent by "the return address email").

quicksketch’s picture

This problem should be fixed in the 1.5 and greater versions of webform (no need to apply the patch now). Try running the latest version and see if the problem still occurs.

summit’s picture

Subscribing
greetings,
Martijn

Anonymous’s picture

Status: Fixed » Closed (fixed)

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