Forum OpenACS Q&A: Polls error

Collapse
Posted by Herbert Samuels on
I get the following error when I try to add a poll in 3.2.2b3:
Invalid date: 5 08 2000
         while executing
     "error "Invalid date: $month $day $year""
         invoked from within
     "if {[string match "" $month]  || [string match "" $day]  || 
[string match "" $year]  || $month < 1 || $month > 12  || $day < 1 || 
$day > 31  || $year  ..."
         (procedure "ns_buildsqldate" line 12)
         invoked from within
     "ns_buildsqldate  [ns_set get $formdata ColValue.[ns_urlencode 
$column].month]  [ns_set get $formdata ColValue.[ns_urlencode 
$column].day]  [ns_set get ..."
         invoked from within
     "set value [ns_buildsqldate  [ns_set get $formdata 
ColValue.[ns_urlencode $column].month]  [ns_set get $formdata 
ColValue.[ns_urlencode $column].day]   ..."
         ("date" arm line 2)
         invoked from within
     "switch $type {
                 
                 date      {
                     set value [ns_buildsqldate  [ns_set get $formdata 
ColValue.[ns_urlencode $column].month]  [ns_set get $formdat ..."
         invoked from within
     "if [string match $value ""] {
             switch $type {
                 
                 date      {
                     set value [ns_buildsqldate  [ns_set get $formdata 
ColValue.[ns_urlencode ..."
         (procedure "ns_dbformvalue" line 12)
         invoked from within
     "ns_dbformvalue [ns_conn form] start_date date start_date"
         (file "/brooklynxweb/acspg/www/admin/poll/poll-new-2.tcl" 
line 50)
         invoked from within
     "source $script"
         invoked from within
     "if ![file exists $script] {
                     ns_returnnotfound $conn
             } else {
                     source $script
             }"
         (procedure "ns_sourceproc" line 3)
         invoked from within
     "ns_sourceproc cns63 {}"

Any clues? Thanks!
Collapse
2: Response to Polls error (response to 1)
Posted by Michael A. Cleverly on
The above date will bomb because one of the checks ns_buildsqldate does is to make sure that day is not less than 1 or greater than 31.  The 08 is interpreted by Tcl as being an octal value instead of an integer value.  (The function is defined in the Tcl privart library directory in the file ad-aolserver-3.tcl.preload beginning at line 545.)

It seems this function would be a tad bit more robust if it stripped and leading zeros off of the day... I've just checked in a new version of ad-aolserver-3.tcl.preload that does this.  This problem would only occur for the 8th & 9th of the month.  So good thing you didn't wait until Wednesday to add a poll! 😊

(If you are running AOLserver 2.3, and not 3.0, then my changed ns_buildsqldate code won't do you any good, and you'll need to poke around in modules/tcl under the AOLserver home and find where it is declared.)