From 6c70c25a24e3a6bcc8a7e4b1fddb51ce941975ea Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Thu, 30 Oct 2025 10:25:57 +0000 Subject: [PATCH] Bug 17387: reindex biblio/item on restore --- Koha/Old/Biblio.pm | 7 ++++++- Koha/Old/Item.pm | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Koha/Old/Biblio.pm b/Koha/Old/Biblio.pm index 7d4200cb743..7984fb918d2 100644 --- a/Koha/Old/Biblio.pm +++ b/Koha/Old/Biblio.pm @@ -25,6 +25,7 @@ use Koha::Biblioitem; use Koha::Biblio::Metadata; use Koha::Old::Biblio::Metadatas; use Koha::Old::Biblioitems; +use Koha::SearchEngine::Indexer; =head1 NAME @@ -140,7 +141,8 @@ sub to_api_mapping { Restores the deleted biblio record back to the biblio table along with its biblioitems and metadata. This removes the record from the deleted tables -and re-inserts it into the active tables. +and re-inserts it into the active tables. The biblio record will be reindexed +after restoration. Returns the newly restored Koha::Biblio object. @@ -169,6 +171,9 @@ sub restore { $biblioitem->delete; $self->delete; + my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + $indexer->index_records( $new_biblio->biblionumber, "specialUpdate", "biblioserver" ); + return $new_biblio; } diff --git a/Koha/Old/Item.pm b/Koha/Old/Item.pm index fef7b8879f2..75991d3f05c 100644 --- a/Koha/Old/Item.pm +++ b/Koha/Old/Item.pm @@ -19,7 +19,10 @@ use Modern::Perl; use base qw(Koha::Object); +use Koha::Biblio; +use Koha::Exceptions; use Koha::Item; +use Koha::SearchEngine::Indexer; =head1 NAME @@ -37,6 +40,9 @@ Koha::Old::Item - Koha Old::Item Object class Restores the deleted item record back to the items table. This removes the record from the deleteditems table and re-inserts it into the items table. +The biblio record will be reindexed after restoration. + +Throws an exception if the biblio record does not exist. Returns the newly restored Koha::Item object. @@ -45,6 +51,11 @@ Returns the newly restored Koha::Item object. sub restore { my ($self) = @_; + my $biblio = Koha::Biblios->find( $self->biblionumber ); + + Koha::Exceptions::ObjectNotFound->throw("Bibliographic record not found for item") + unless $biblio; + my $item_data = $self->unblessed; delete $item_data->{deleted_on}; @@ -52,6 +63,9 @@ sub restore { $self->delete; + my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + $indexer->index_records( $new_item->biblionumber, "specialUpdate", "biblioserver" ); + return $new_item; } -- 2.39.5