Bug 12478: Remove empty limit parameter
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Oct 2015 10:34:54 +0000 (11:34 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 26 Apr 2016 13:00:50 +0000 (10:00 -0300)
If no limit are passed, the url will contain '&limit=' anyway.
It is not necessary and can be avoided easily

Test plan:
1/ Search for a term in your catalogue
2/ Hover over a link in the facet area
3/ The link is
cgi-bin/koha/opac-search.pl?idx=kw&q=your_term&limit=&limit=[...]

With this patch, the empty limit parameter does not appear.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

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

Koha/SearchEngine/Elasticsearch/QueryBuilder.pm

index 09d65a6..30bf6f8 100644 (file)
@@ -223,8 +223,9 @@ sub build_query_compat {
     my $simple_query = $operands->[0] if @$operands == 1;
     my $query_desc   = $simple_query;
     my $limit        = $self->_join_queries( $self->_convert_index_strings(@$limits));
-    my $limit_cgi =
-      '&limit=' . join( '&limit=', map { uri_escape_utf8($_) } @$orig_limits );
+    my $limit_cgi = ( $orig_limits and @$orig_limits )
+      ? '&limit=' . join( '&limit=', map { uri_escape_utf8($_) } @$orig_limits )
+      : '';
     my $limit_desc = "$limit" if $limit;
     return (
         undef,  $query,     $simple_query, $query_cgi, $query_desc,