Bug 8435: (follow-up) use a transaction for unit tests
[koha.git] / C4 / Search.pm
index c550385..bec1f89 100644 (file)
@@ -751,7 +751,7 @@ sub _remove_stopwords {
     my @stopwords_removed;
 
     # phrase and exact-qualified indexes shouldn't have stopwords removed
-    if ( $index !~ m/phr|ext/ ) {
+    if ( $index !~ m/,(phr|ext)/ ) {
 
 # remove stopwords from operand : parse all stopwords & remove them (case insensitive)
 #       we use IsAlpha unicode definition, to deal correctly with diacritics.
@@ -956,6 +956,7 @@ sub getIndexes{
                     'Corporate-name-heading',
                     'Corporate-name-see',
                     'Corporate-name-seealso',
+                    'Country-publication',
                     'ctype',
                     'date-entered-on-file',
                     'Date-of-acquisition',
@@ -1386,7 +1387,7 @@ sub buildQuery {
 
                 # Set default structure attribute (word list)
                 my $struct_attr = q{};
-                unless ( $indexes_set || !$index || $index =~ /(st-|phr|ext|wrdl|nb|ns)/ ) {
+                unless ( $indexes_set || !$index || $index =~ /,(st-|phr|ext|wrdl)/ || $index =~ /^(nb|ns)$/ ) {
                     $struct_attr = ",wrdl";
                 }
 
@@ -1404,7 +1405,7 @@ sub buildQuery {
                 }
 
                 if ($auto_truncation){
-                                       unless ( $index =~ /(st-|phr|ext)/ ) {
+                        unless ( $index =~ /,(st-|phr|ext)/ ) {
                                                #FIXME only valid with LTR scripts
                                                $operand=join(" ",map{
                                                                                        (index($_,"*")>0?"$_":"$_*")
@@ -1815,7 +1816,7 @@ sub searchResults {
         my $onloan_count          = 0;
         my $longoverdue_count     = 0;
         my $other_count           = 0;
-        my $wthdrawn_count        = 0;
+        my $withdrawn_count        = 0;
         my $itemlost_count        = 0;
         my $hideatopac_count      = 0;
         my $itembinding_count     = 0;
@@ -1902,7 +1903,7 @@ sub searchResults {
                 # is item on the reserve shelf?
                 my $reservestatus = '';
 
-                unless ($item->{wthdrawn}
+                unless ($item->{withdrawn}
                         || $item->{itemlost}
                         || $item->{damaged}
                         || $item->{notforloan}
@@ -1925,19 +1926,19 @@ sub searchResults {
                 }
 
                 # item is withdrawn, lost, damaged, not for loan, reserved or in transit
-                if (   $item->{wthdrawn}
+                if (   $item->{withdrawn}
                     || $item->{itemlost}
                     || $item->{damaged}
                     || $item->{notforloan}
                     || $reservestatus eq 'Waiting'
                     || ($transfertwhen ne ''))
                 {
-                    $wthdrawn_count++        if $item->{wthdrawn};
+                    $withdrawn_count++        if $item->{withdrawn};
                     $itemlost_count++        if $item->{itemlost};
                     $itemdamaged_count++     if $item->{damaged};
                     $item_in_transit_count++ if $transfertwhen ne '';
                     $item_onhold_count++     if $reservestatus eq 'Waiting';
-                    $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
+                    $item->{status} = $item->{withdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
 
                     # can place a hold on a item if
                     # not lost nor withdrawn
@@ -1946,7 +1947,7 @@ sub searchResults {
                     $can_place_holds = 1
                       if (
                            !$item->{itemlost}
-                        && !$item->{wthdrawn}
+                        && !$item->{withdrawn}
                         && ( !$item->{damaged} || C4::Context->preference('AllowHoldsOnDamagedItems') )
                         && ( !$item->{notforloan} || $item->{notforloan} < 0 )
                       );
@@ -1954,7 +1955,7 @@ sub searchResults {
                     $other_count++;
 
                     my $key = $prefix . $item->{status};
-                    foreach (qw(wthdrawn itemlost damaged branchname itemcallnumber)) {
+                    foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) {
                         $other_items->{$key}->{$_} = $item->{$_};
                     }
                     $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
@@ -2026,7 +2027,7 @@ sub searchResults {
         $oldbiblio->{onloanplural}         = 1 if $onloan_count > 1;
         $oldbiblio->{othercount}           = $other_count;
         $oldbiblio->{otherplural}          = 1 if $other_count > 1;
-        $oldbiblio->{wthdrawncount}        = $wthdrawn_count;
+        $oldbiblio->{withdrawncount}        = $withdrawn_count;
         $oldbiblio->{itemlostcount}        = $itemlost_count;
         $oldbiblio->{damagedcount}         = $itemdamaged_count;
         $oldbiblio->{intransitcount}       = $item_in_transit_count;