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.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | webform_check-empy-values_dev.patch | 858 bytes | ashtonium |
| #6 | webform_check-empy-values_1.4.patch | 882 bytes | ashtonium |
| #3 | webform.from_none1.patch | 1.18 KB | scor |
| #1 | webform_patch_0.txt | 1.22 KB | scafmac |
Comments
Comment #1
scafmac commentedBeen testing this patch and it is ready to be committed.
Comment #2
jonathan_hunt commentedThis fix worked for me. Applied by hand to webform.module,v 1.113.2.38 2007/06/13
Comment #3
scor commentedAlready posted a patch 2 weeks ago : http://drupal.org/node/155915
Attached is the patch against the latest webform.module 1.113.2.42
Comment #4
scor commentedThis issue has been reported again: no emails ([None] and [Default] Mail Settings are switched)
Set it to critical.
Comment #5
ashtonium commentedThe 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.
Comment #6
ashtonium commentedThis is the version for those looking to patch this issue in their install of webform 5.x-1.4
Comment #7
ashtonium commentedand this is the edited version against the latest development snapshot.
- applied cleanly and fixed the issue
RTBC
Comment #8
scor commentedThat's normal, the character is broken.... it should be AF
I didn't want to file an issue just for such a small typo.
Comment #9
scor commentedoops... commented at the same time.
back to 1.x.dev
Comment #10
solutionsphp commentedApplied 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?
Comment #11
jonathan_hunt commentedMissing form fields in email are another issue, see for example http://drupal.org/node/155743
Comment #12
mo6The patch in #16 applies and fixes the issue. Please commit.
Comment #13
mo6Oops, I meant #6 not #16.
Comment #14
neurojavi commentedHi:
#6 works for me (version 5.x-1.4)
Many thanks.-
Comment #15
David Lesieur commentedPatch #6 works here too.
Comment #16
quicksketchApplied. Thanks so much for the exhaustive confirmations. Makes maintenance so much easier. Thanks scor for the patch!
Comment #17
fuquam commentedApplied 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").
Comment #18
quicksketchThis 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.
Comment #19
summit commentedSubscribing
greetings,
Martijn
Comment #20
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.