Bugzilla – Attachment 122889 Details for
Bug 22690
Merging records with many items too slow (Elasticsearch)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22690: (QA follow-up) Index also source biblio when calling move_to_biblio()
Bug-22690-QA-follow-up-Index-also-source-biblio-wh.patch (text/plain), 4.27 KB, created by
Jonathan Druart
on 2021-07-16 12:49:37 UTC
(
hide
)
Description:
Bug 22690: (QA follow-up) Index also source biblio when calling move_to_biblio()
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-07-16 12:49:37 UTC
Size:
4.27 KB
patch
obsolete
>From b03fe28464fd48f5b2e31b168ab07cee4f62818d Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@helsinki.fi> >Date: Tue, 25 May 2021 18:34:33 +0300 >Subject: [PATCH] Bug 22690: (QA follow-up) Index also source biblio when > calling move_to_biblio() >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >We need to update the search index record for the old biblio where the >item was moved from to keep the item info in search index up-to-date. > >To test: >1) $ prove t/db_dependent/Koha/SearchEngine/Indexer.t > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 22 ++++++++++++++-------- > t/db_dependent/Koha/SearchEngine/Indexer.t | 2 +- > 2 files changed, 15 insertions(+), 9 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 61532967344..6722dcfb7c0 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1215,27 +1215,33 @@ sub move_to_biblio { > > return unless $self->biblionumber != $to_biblio->biblionumber; > >- my $biblionumber = $to_biblio->biblionumber; >+ my $from_biblionumber = $self->biblionumber; >+ my $to_biblionumber = $to_biblio->biblionumber; > > # Own biblionumber and biblioitemnumber > $self->set({ >- biblionumber => $biblionumber, >+ biblionumber => $to_biblionumber, > biblioitemnumber => $to_biblio->biblioitem->biblioitemnumber > })->store({ skip_record_index => $params->{skip_record_index} }); > >+ unless ($params->{skip_record_index}) { >+ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ $indexer->index_records( $from_biblionumber, "specialUpdate", "biblioserver" ); >+ } >+ > # Acquisition orders > my $orders = $self->item_orders; > if ($orders) { >- $orders->update({ biblionumber => $biblionumber }, { no_triggers => 1 }); >+ $orders->update({ biblionumber => $to_biblionumber }, { no_triggers => 1 }); > } > > # Holds >- $self->holds->update({ biblionumber => $biblionumber }); >+ $self->holds->update({ biblionumber => $to_biblionumber }); > > # hold_fill_target (there's no Koha object available) > my $hold_fill_target = $self->_result->hold_fill_target; > if ($hold_fill_target) { >- $hold_fill_target->update({ biblionumber => $biblionumber }); >+ $hold_fill_target->update({ biblionumber => $to_biblionumber }); > } > > # tmp_holdsqueues - Can't update with DBIx since the table is missing a primary key >@@ -1245,16 +1251,16 @@ sub move_to_biblio { > sub { > my ($storage, $dbh, @cols) = @_; > >- $dbh->do("UPDATE tmp_holdsqueue SET biblionumber=? WHERE itemnumber=?", undef, $biblionumber, $self->itemnumber); >+ $dbh->do("UPDATE tmp_holdsqueue SET biblionumber=? WHERE itemnumber=?", undef, $to_biblionumber, $self->itemnumber); > } > ); > > # linktrackers > my $schema = Koha::Database->new()->schema(); > my $linktrackers = $schema->resultset('Linktracker')->search({ itemnumber => $self->itemnumber }); >- $linktrackers->update_all({ biblionumber => $biblionumber }); >+ $linktrackers->update_all({ biblionumber => $to_biblionumber }); > >- return $biblionumber; >+ return $to_biblionumber; > } > > =head2 Internal methods >diff --git a/t/db_dependent/Koha/SearchEngine/Indexer.t b/t/db_dependent/Koha/SearchEngine/Indexer.t >index 663f0bafdf7..9ee997c263d 100755 >--- a/t/db_dependent/Koha/SearchEngine/Indexer.t >+++ b/t/db_dependent/Koha/SearchEngine/Indexer.t >@@ -178,7 +178,7 @@ subtest 'Test indexer calls' => sub { > > warnings_are{ > $item3->move_to_biblio($biblio2); >- } [$engine,"Koha::Item"], "index_records is called for $engine when moving an item to another biblio (Item->move_to_biblio)"; >+ } [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called twice for $engine when moving an item to another biblio (Item->move_to_biblio)"; > warnings_are{ > $item4->move_to_biblio($biblio2, { skip_record_index => 1 }); > } undef, "index_records is not called for $engine when moving an item to another biblio (Item->move_to_biblio) if skip_record_index passed"; >-- >2.20.1
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 22690
:
90061
|
90115
|
90116
|
92828
|
94505
|
97696
|
98143
|
98210
|
98211
|
99376
|
99379
|
100316
|
104796
|
104797
|
104871
|
105445
|
106144
|
108777
|
109694
|
110991
|
110994
|
111196
|
111207
|
111236
|
111237
|
112100
|
112184
|
112567
|
112569
|
112754
|
113308
|
113309
|
113941
|
113942
|
113967
|
113968
|
118226
|
118227
|
118229
|
118231
|
118391
|
119433
|
119434
|
120820
|
120821
|
120852
|
120853
|
121389
|
121392
|
121474
|
121516
|
121517
|
121518
|
121519
|
121520
|
122846
|
122847
|
122848
|
122849
|
122850
|
122886
|
122887
|
122888
|
122889
|
122890
|
122936
|
122938
|
122939
|
123029
|
123030
|
123031
|
123032
|
123033
|
123034
|
123035
|
123036
|
123037
|
123038
|
123039
|
123040
|
123041
|
123042
|
123044
|
123062
|
123481
|
123482
|
123483
|
123484
|
123485
|
123486
|
123487
|
123488
|
123489
|
123490
|
123491
|
123492
|
123493
|
123494
|
123495
|
123496
|
123497
|
124176
|
124188
|
124257