From 1271acfa2b5ea8b16880f511e997d8862460daca Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Fri, 17 Jun 2022 10:13:41 +0000
Subject: [PATCH] Bug 30327: Fix tests

Corrected variable name on update to match everywhere else

Added a default value for limit in buildQuery and only append limit if it has content
---
 C4/Search.pm                                                  | 4 ++--
 .../atomicupdate/bug_30327_add_sortComponents_syspref.pl      | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/C4/Search.pm b/C4/Search.pm
index 73484ac683..1ba56c8384 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1217,7 +1217,7 @@ sub buildQuery {
     my $query_cgi;
     my $query_type;
 
-    my $limit;
+    my $limit = q{};
     my $limit_cgi;
     my $limit_desc;
 
@@ -1328,7 +1328,7 @@ sub buildQuery {
         # This is needed otherwise ccl= and &limit won't work together, and
         # this happens when selecting a subject on the opac-detail page
         my $original_q = $q; # without available part
-        $q .= $limit;
+        $q .= $limit if $limit;
         return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
     }
     if ( $query =~ /^cql=/ ) {
diff --git a/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl b/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl
index 0cb8f16dac..7c64d24c53 100755
--- a/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl
+++ b/installer/data/mysql/atomicupdate/bug_30327_add_sortComponents_syspref.pl
@@ -8,8 +8,8 @@ return {
         my ($dbh, $out) = @$args{qw(dbh out)};
         $dbh->do(q{
             INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
-            ('ComponentsSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
-            ('ComponentsSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice')
+            ('ComponentSortField','title','call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
+            ('ComponentSortOrder','asc','asc|dsc|az|za','Specify the default sort order','Choice')
         });
         say $out "Added ComponentsSortField and ComponentsSortOrder sysprefs";
     },
-- 
2.30.2