From aeb33f91a500c9b022777e858df9c916932f50e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= Date: Tue, 20 Oct 2020 14:11:16 +0200 Subject: [PATCH] Bug 26750: Deleted items not indexed After deleting an item it is still searchable in the index. Similar to bug 26507 where record is reindexed before the database is changed. To test: 1. Delete an item 2. Search the barcode in the main search box. You'll find the original record but wiht hte deleted item missing. 3. Apply patch. 4. Repeat steps 1-2 (with another item). No record should be found. Note to test you have to have the indexer running, not the cron job, and it needs to be running fast so that the index is updated before the delete takes place Signed-off-by: Chris Cormack Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart (cherry picked from commit 395bb760394e6947303de7e342882148944e9026) Signed-off-by: Lucas Gass --- Koha/Item.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index bc22f70df9..c72c843ea4 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -194,6 +194,8 @@ sub delete { # FIXME check the item has no current issues # i.e. raise the appropriate exception + my $result = $self->SUPER::delete; + my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" ) unless $params->{skip_record_index}; @@ -203,7 +205,7 @@ sub delete { logaction( "CATALOGUING", "DELETE", $self->itemnumber, "item" ) if C4::Context->preference("CataloguingLog"); - return $self->SUPER::delete; + return $result; } =head3 safe_delete -- 2.39.5