Forum OpenACS Q&A: Upload portrait broken?

Collapse
Posted by Nick Carroll on
Hi,

I was just wondering if anyone is having problems with uploading a portrait in the HEAD version of OpenACS? I think it might be broken, as I get the following error...

Any ideas how to fix this?

can't use empty string as operand of "!"
while executing
"if { ![parameter::get_from_package_key -package_key acs-subsite -parameter SolicitPortraitP] } {
if { ![acs_user::site_wide_admin_p] } {
..."
(procedure "subsite::upload_allowed" line 3)
invoked from within
"subsite::upload_allowed"
invoked from within
"if [empty_string_p $user_id] {
subsite::upload_allowed
set user_id $current_user_id
set admin_p 0
} else {
set admin_p 1
}"
("uplevel" body line 19)
invoked from within
"uplevel {
ad_page_contract {
Uploading user portraits

Collapse
Posted by Nick Carroll on
The error only occurs when a subsite is mounted using Jeff's install.xml template method. It doesn't occur when subsites are created as per normal.

Jeff, do you get this problem when you try to upload a portrait in your CoP application?

Collapse
Posted by Orzenil Silva Junior on
Hi Nick,

I had the same error in a install where i have two instances of acs-subsite.

In parameter::get_from_package_key documentation:

"switches:

-package_key (required) - what package to get the parameter from. we will try to get the package_id from the package_key. this may cause an error if there are more than one instance of this package"

I could prevent this error just changing subsite::upload_allowed from packages/acs-subsite/tcl/subsite-procs.tcl :

change:

if { ![parameter::get_from_package_key -package_key acs-subsite -parameter SolicitPortraitP] } {

to

if { ![parameter::get_from_package_key -package_key acs-subsite -parameter SolicitPortraitP -default 1] } {

I am not sure it is a good fix so i did not put it as a patch but works for me

Collapse
Posted by Nick Carroll on
Hi Orzenil,

I thought about defaulting it to 1, but I'm not sure if that is a viable solution.

Would [parameter::get -parameter SolicitPortraitP] do the trick?

Collapse
Posted by Nick Carroll on
Ok, I can confirm too that the bug occurs when more than one acs-subsite is mounted.
Collapse
Posted by Jeff Davis on
It should not be using the package key to get the parameter
and it should have a default. If someone want to make that
change and commit or submit a patch they should.
Collapse
Posted by Orzenil Silva Junior on
Jeff, Nick,

i made the changes to subsite-procs.tcl in my openacs-5-1-5 install with two subsites mounted and it worked good for me not using the package key to get the parameter and having a default.

patch was submitted:https://openacs.org/bugtracker/openacs/bug?format=table&bug_number=2357

Collapse
Posted by Nick Carroll on
Cool, thanks Orzenil!