Forum OpenACS Q&A: Download module error

Collapse
Posted by Christopher Silva on
Hi!
When I try to "Add a rule" to a download file (in the download module)
I keep getting a server error with the download-add-rule-2.tcl file.
I'm using AOLserver/3.2+ad12. It was giving me another error before,
but I got that fixed reading about it on https://openacs.org/bboard/q-and-a-fetch-msg.tcl?msg_id=0000iV .
Collapse
Posted by Christopher Silva on
This is what the defaultacs.log is giving me when I try to "Add a rule" to a download file:

"error "The entry for $field_name, "$string" is not an integer"" (procedure "validate_integer" line 3) invoked from within "validate_integer version_id $version_id" (file "/var/lib/aolserver/servers/defaultacs/www/download/admin/download-add -rule-2.tcl" line 15) invoked from within "source $script" (procedure "ns_sourceproc" line 6) invoked from within "ns_sourceproc cns579 {}"
Collapse
Posted by Vinod Kurup on
Hi Christopher,

First thing - when posting logs, enclose them in <pre> tags and choose the HTML option. This makes it a lot easier to read.

It seems that the download module doesn't properly handle the case when version_id is null.

In download-add-rule-2.tcl, change:

validate_integer version_id $version_id
to
validate_integer_or_null version_id $version_id
At the bottom of the same file, change:
insert into download_rules (rule_id, version_id, download_id, visibility, price, currency) values ($new_rule_id, '$version_id', $download_id, '$QQvisibility', '$price', '$QQcurrency')"
to
insert into download_rules (rule_id, version_id, download_id, visibility, price, currency) values ($new_rule_id, [ad_decode $version_id "" [db_null] "$version_id"], $download_id, '$QQvisibility', '$price', '$QQcurrency')"
You'll have to make these same changes in the file download-update-rule.tcl

This seems to make it work, but I haven't tested it extensively. Good luck!