Bug 10281: searching for a search domain fails
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Sat, 18 May 2013 13:09:23 +0000 (09:09 -0400)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sun, 19 May 2013 12:39:30 +0000 (08:39 -0400)
For reasons I cannot fathom, the split() in handling multi-branch
limits was not coming up with a valid search group code. Replacing
the split() with a substr() and creating the CGI parameter as a string
rather than as an arrayref fixes the problem. This problem may not
affect all installations, since I tested this exact feature just under
two months ago and it worked fine, and none of the relevant code has
been changed since then that I can see.

To test:
1) Create search group, and add at least one library to it, in
   /cgi-bin/koha/admin/branches.pl
2) Apply patch
3) Try doing a search limited to your search group, making sure that
   the search will match items that belong to a library in the search
   group
4) Sign off

Signed-off-by: Magnus Enger <magnus@enger.priv.no>
I have failed to recreate the problem on three different dev installs,
both on Ubuntu and Debian, but the current patch does not break
anything as far as I can tell, so I'm signing off.

I tested with two libraries in the same search domain, with each
library owning a different book by the same author. Searching for
the author in
- all libraries,
- individual libraries and
- the search domain that contains both libraries
all return the expected results.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.
I couldn't reproduce the problem, but didn't find any regressions.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
catalogue/search.pl
opac/opac-search.pl

index 8624b3b..258c381 100755 (executable)
@@ -412,7 +412,8 @@ my @operands = $cgi->param('q');
 my @limits = $cgi->param('limit');
 
 if($params->{'multibranchlimit'}) {
-    push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    push @limits, $multibranch if ($multibranch ne  '()');
 }
 
 my $available;
index 363a11e..b527745 100755 (executable)
@@ -65,10 +65,13 @@ my $cgi = new CGI;
 
 my $branch_group_limit = $cgi->param("branch_group_limit");
 if ( $branch_group_limit ) {
-    if ( $branch_group_limit =~ /^multibranchlimit/ ) {
+    if ( $branch_group_limit =~ /^multibranchlimit-/ ) {
+        # For search groups we are going to convert this branch_group_limit CGI
+        # parameter into a multibranchlimit CGI parameter for the purposes of
+        # actually performing the query
         $cgi->param(
             -name => 'multibranchlimit',
-            -values => [ ( split( 'multibranchlimit-', $branch_group_limit ) )[1] ]
+            -values => substr($branch_group_limit, 17)
         );
     } else {
         $cgi->append(
@@ -403,7 +406,8 @@ my @limits = $cgi->param('limit');
 @limits = map { uri_unescape($_) } @limits;
 
 if($params->{'multibranchlimit'}) {
-    push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+    push @limits, $multibranch if ($multibranch ne  '()');
 }
 
 my $available;