Bug 15810: Make sure the CGI->param is not called in a list context when creating...
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 12 Feb 2016 14:33:57 +0000 (14:33 +0000)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Mon, 22 Feb 2016 20:32:18 +0000 (20:32 +0000)
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 <katrin.fischer@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com

opac/opac-shelves.pl
virtualshelves/shelves.pl

index 76d632a..ef418e0 100755 (executable)
@@ -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;
index 74e31e4..eab6c17 100755 (executable)
@@ -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;