Bugzilla – Attachment 189106 Details for
Bug 17387
Add an undelete feature for items/biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17387: reindex biblio/item on restore
Bug-17387-reindex-biblioitem-on-restore.patch (text/plain), 2.66 KB, created by
Jacob O'Mara
on 2025-11-05 15:59:42 UTC
(
hide
)
Description:
Bug 17387: reindex biblio/item on restore
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-11-05 15:59:42 UTC
Size:
2.66 KB
patch
obsolete
>From 6c70c25a24e3a6bcc8a7e4b1fddb51ce941975ea Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17387
:
188670
|
188671
|
188672
|
188673
|
188674
|
188675
|
188676
|
188677
|
188678
|
188679
|
188680
|
188681
|
188682
|
188683
|
188684
|
188685
|
188686
|
188687
|
188688
|
188689
|
188690
|
188691
|
188692
|
188693
|
188694
|
188695
|
188696
|
188697
|
188698
|
188699
|
188700
|
188701
|
188780
|
188781
|
188782
|
188783
|
188784
|
188785
|
188786
|
188787
|
188788
|
188789
|
188790
|
188791
|
188792
|
188793
|
188794
|
188795
|
189046
|
189047
|
189048
|
189049
|
189050
|
189051
|
189052
|
189053
|
189054
|
189055
|
189056
|
189057
|
189058
|
189059
|
189060
|
189061
|
189062
|
189082
|
189083
|
189084
|
189085
|
189086
|
189087
|
189088
|
189089
|
189090
|
189091
|
189092
|
189093
|
189094
|
189095
|
189096
|
189097
|
189098
|
189099
|
189100
|
189101
|
189102
|
189103
|
189104
|
189105
| 189106 |
189107
|
189108
|
189109
|
189110
|
189111
|
189112
|
189113
|
189114
|
189115
|
189116
|
189117
|
189118
|
189119