When attempting to choose a starting/ending date greater than 100 years ago (i.e. '-120 years' or '120 years ago') the date errors and returns 1969.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | webform_date_fix_3-15-2012.patch | 2.3 KB | weekbeforenext |
When attempting to choose a starting/ending date greater than 100 years ago (i.e. '-120 years' or '120 years ago') the date errors and returns 1969.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | webform_date_fix_3-15-2012.patch | 2.3 KB | weekbeforenext |
Comments
Comment #1
weekbeforenextI encountered a similar problem when I upgraded from Webform 3.11 to 3.16. I have been able to set a date range up to +/-25 years and the year select box works properly. If I increase to +/- 26 years, the select box shows 1969-1986.
Comment #2
quicksketchSo in short this issue *sounds like* any date before 1970, whether it is is relative (-26 years) or absolute (Dec 1, 1960), the form will throw a validation error of "The entered date must be Dec 31 1969 or earlier."
Comment #3
weekbeforenextNot exactly. I set the date range as follows:
Start Date: Dec 31 1948
End Date: Dec 31 1958
In this instance, the year select box rendered properly and the error wasn't thrown. I think it has to do with the number of years that are options. Seems like you aren't allowed to create a range of more than 50 years.
Comment #4
quicksketchHuh, interesting. Thanks, the more information the better.
Comment #5
weekbeforenextI've located the problem but haven't quite figured it out yet. The bug happens in the webform_strtodate function in weform.module.
Start Date: "Dec 31 1900" becomes "1969-12-31"
End Date: "Dec 31 2050" becomes "1969-12-31"
Start Date: "-26 years" becomes "1986-03-07"
End Date: "+26 years" becomes "1969-12-31"
Start Date: "-25 years" becomes "1987-03-07"
End Date: "+25 years" becomes "2037-03-07"
Start Date: "-2 years" becomes "2010-03-07"
End Date: "+26 years" becomes "1969-12-31"
I will revisit my investigation tomorrow, but I just thought I'd share what I found in case it helps determine a fix sooner.
Comment #6
weekbeforenextLooks like the problem is with the php function strtotime().
The problem with dates before 1970 is due to:
"Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though." - http://us2.php.net/manual/en/function.strtotime.php
I can actually get dates prior to 1970 to work down to Dec 31 1901. Dec 31 1900 breaks.
The problem with +26 years is due to:
"As with each of the time-related functions, and as mentioned in the time() notes, strtotime() is affected by the year 2038 bug on 32-bit systems." - http://us2.php.net/manual/en/function.strtotime.php#80541
Some people have posted work arounds and I will investigate that now. Just wanted to post this as an explanation of the problem. I am on a Windows server and it is most likely 32-bit. Not sure how I am able to do the dates earlier than 1970 though.
Comment #7
weekbeforenextIt may not be pretty, but I fixed these exceptions in webform.module for rendering:
The validation still needs some work.
Comment #8
quicksketchThanks @weekbeforenext! Being on 64-bit, *nix machines, it's unlikely that I would be able to reproduce the problem, so appreciate your sleuthing. To complete the picture, what version of PHP are you running? Webform already requires PHP 5.1, so I'm a bit surprised that the strtotime() limitations are affecting you.
Could you make your changes available as a patch?
Comment #9
weekbeforenextI'm testing on PHP 5.2.8 but I first experienced the problems on PHP 5.2.14. I'm pretty sure my sites are running on 32-bit Windows.
I will work on creating a patch. I still need to make modifications to the validation. I'm glad to help out.
Comment #10
weekbeforenextAttached is a patch for what I've done so far. I still need to look at the validation portion.
Comment #11
ardnet commentedHi, was just wondering whether this issue has already been fixed, as I got the same problem now.
Just FYI, I'm using Webform version 6.x-3.18 and PHP ver. 5.3.3, and whether it's necessary to do Webform update just to resolve this issue.
Thanks
Comment #12
danchadwick commentedThe 6.x branch is receiving critical bug fixes only.