From d6329e4f96e46a5e2fbe0ced4d385c42d47e2a84 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Feb 2016 14:33:57 +0000 Subject: [PATCH] Bug 15810: Make sure the CGI->param is not called in a list context when creating private shelves This patch fixes the following bug: If OpacAllowPublicListCreation is set to "not allow", the creation of a private list raises an error at the OPAC. CGI->param is called in a list context and some parameters are not filled from the template if the pref is set to "not allow". To make sure we don't have a "Odd number of elements in anonymous hash", we force the context to scalar. Test plan: 1/ Set OpacAllowPublicListCreation to "not allow" 2/ Create private and public lists at the OPAC and the intranet => Everything should work fine with this patch applied Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- opac/opac-shelves.pl | 14 +++++++------- virtualshelves/shelves.pl | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 76d632a785..ef418e0901 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -72,13 +72,13 @@ if ( $op eq 'add_form' ) { if ( $loggedinuser ) { eval { $shelf = Koha::Virtualshelf->new( - { shelfname => $query->param('shelfname'), - sortfield => $query->param('sortfield'), - category => $query->param('category') || 1, - allow_add => $query->param('allow_add'), - allow_delete_own => $query->param('allow_delete_own'), - allow_delete_other => $query->param('allow_delete_other'), - owner => $loggedinuser, + { shelfname => scalar $query->param('shelfname'), + sortfield => scalar $query->param('sortfield'), + category => scalar $query->param('category') || 1, + allow_add => scalar $query->param('allow_add'), + allow_delete_own => scalar $query->param('allow_delete_own'), + allow_delete_other => scalar $query->param('allow_delete_other'), + owner => scalar $loggedinuser, } ); $shelf->store; diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index 74e31e4380..eab6c17f70 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -65,13 +65,13 @@ if ( $op eq 'add_form' ) { } elsif ( $op eq 'add' ) { eval { $shelf = Koha::Virtualshelf->new( - { shelfname => $query->param('shelfname'), - sortfield => $query->param('sortfield'), - category => $query->param('category'), - allow_add => $query->param('allow_add'), - allow_delete_own => $query->param('allow_delete_own'), - allow_delete_other => $query->param('allow_delete_other'), - owner => $query->param('owner'), + { shelfname => scalar $query->param('shelfname'), + sortfield => scalar $query->param('sortfield'), + category => scalar $query->param('category'), + allow_add => scalar $query->param('allow_add'), + allow_delete_own => scalar $query->param('allow_delete_own'), + allow_delete_other => scalar $query->param('allow_delete_other'), + owner => scalar $query->param('owner'), } ); $shelf->store; -- 2.39.5