From 72c0383d6a5d87517cafea955222722994124b16 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 23 Apr 2021 16:48:52 +0100
Subject: [PATCH] Bug 28210: Pass skip_record_index through LostItem

This patch restores the skip_record_index optional parameter for
LostItem and passes it through to MarkIssueReturned as required.
---
 C4/Circulation.pm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 3ec9a29075..26aa616203 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -3815,12 +3815,21 @@ sub ReturnLostItem{
 
 =head2 LostItem
 
-  LostItem( $itemnumber, $mark_lost_from, $force_mark_returned );
+  LostItem( $itemnumber, $mark_lost_from, $force_mark_returned, [$params] );
+
+The final optional parameter, C<$params>, expected to contain
+'skip_record_index' key, which relayed down to Koha::Item/store,
+there it prevents calling of ModZebra index_records,
+which takes most of the time in batch adds/deletes: index_records better
+to be called later in C<additem.pl> after the whole loop.
+
+$params:
+    skip_record_index => 1|0
 
 =cut
 
 sub LostItem{
-    my ($itemnumber, $mark_lost_from, $force_mark_returned) = @_;
+    my ($itemnumber, $mark_lost_from, $force_mark_returned, $params) = @_;
 
     unless ( $mark_lost_from ) {
         # Temporary check to avoid regressions
@@ -3866,7 +3875,7 @@ sub LostItem{
             #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
         }
 
-        MarkIssueReturned($borrowernumber,$itemnumber,undef,$patron->privacy) if $mark_returned;
+        MarkIssueReturned($borrowernumber,$itemnumber,undef,$patron->privacy,$params) if $mark_returned;
     }
 
     # When an item is marked as lost, we should automatically cancel its outstanding transfers.
-- 
2.20.1