Bugzilla – Attachment 186142 Details for
Bug 31460
Merging biblio records with attached item groups losing groups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31460: Merge item groups when merging records
Bug-31460-Merge-item-groups-when-merging-records.patch (text/plain), 2.93 KB, created by
Nick Clemens (kidclamp)
on 2025-09-04 12:28:35 UTC
(
hide
)
Description:
Bug 31460: Merge item groups when merging records
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-09-04 12:28:35 UTC
Size:
2.93 KB
patch
obsolete
>From 81e0e1ea5910626a49a4a72a71f0686854835bbc Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 4 Sep 2025 12:24:07 +0000 >Subject: [PATCH] Bug 31460: Merge item groups when merging records > >Test: >1. Have a record (A) with 3 items. >2. Create an item group with 2 of these items. >3. Have a second record (B) with 4 items >4. Create an item group with 2 of these items. >5. Merge the two records together keeping record A >6. Results will show that all items are moved over to record A, but the item group from record B, is not there. >7. Apply patch >8. Create a new record (C) with 3 items. >9. Create an item group with 2 of these items >10. Merge this into record A >11. The item groups are moved! >--- > Koha/Biblio.pm | 6 ++++++ > t/db_dependent/Koha/Biblio.t | 22 +++++++++++++++++++++- > 2 files changed, 27 insertions(+), 1 deletion(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 964c7992e03..402e8804538 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -2338,6 +2338,12 @@ sub merge_with { > my $from_biblio = Koha::Biblios->find($bn_merge); > $from_biblio->items->move_to_biblio($self); > >+ # Move item groups >+ $from_biblio->item_groups->update( >+ { biblio_id => $ref_biblionumber }, >+ { no_triggers => 1 } >+ ); >+ > # Move article requests > $from_biblio->article_requests->update( > { biblionumber => $ref_biblionumber }, >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index f0d32ee3009..49e6defd676 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -649,7 +649,7 @@ subtest 'bookings() tests' => sub { > }; > > subtest 'merge of records' => sub { >- plan tests => 8; >+ plan tests => 9; > > subtest 'move items' => sub { > plan tests => 9; >@@ -702,6 +702,26 @@ subtest 'merge of records' => sub { > $schema->storage->txn_rollback; > }; > >+ subtest 'move item groups' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $ig1 = $builder->build_object( >+ { class => 'Koha::Biblio::ItemGroups', value => { biblio_id => $biblio1->biblionumber } } ); >+ my $ig2 = $builder->build_object( >+ { class => 'Koha::Biblio::ItemGroups', value => { biblio_id => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $ig1->get_from_storage->biblio_id, $biblio1->biblionumber ); >+ is( $ig2->get_from_storage->biblio_id, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ > subtest 'move article requests' => sub { > plan tests => 3; > $schema->storage->txn_begin; >-- >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 31460
:
186142
|
186178