Bugzilla – Attachment 176428 Details for
Bug 37710
Remove the marc link when removing an item from a bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37710: Remove the marc link when removing an item from a bundle
Bug-37710-Remove-the-marc-link-when-removing-an-it.patch (text/plain), 3.35 KB, created by
Thibault Keromnès
on 2025-01-13 10:24:57 UTC
(
hide
)
Description:
Bug 37710: Remove the marc link when removing an item from a bundle
Filename:
MIME Type:
Creator:
Thibault Keromnès
Created:
2025-01-13 10:24:57 UTC
Size:
3.35 KB
patch
obsolete
>From 5c9ef3321c630540fcb38dc2bbd29c2c60ba6db6 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <bski@laposte.net> >Date: Fri, 20 Sep 2024 16:47:18 +0200 >Subject: [PATCH] Bug 37710: Remove the marc link when removing an item from a > bundle > >A new functionality to automatically add a new MARC link has been added in Bug 29560 (Add option to create MARC links when adding items to bundles). There should also be a way to remove this link when removing the item from the bundle. > >Moreover I don't know if this should be a second bug but since the link is not removed, there can be multiple links if the item is added to a new bundle. > >TEST PLAN: >1 - Apply tests and prove t/db_dependent/Koha/Biblio.t -> should fail >2 - Create a bundle on an item by changing the 7th character of the > leader to c (go to the marc, click on the button at the right of the > field 000 and change the bibliographical level to collection). >3 - Add an item to the bundle (on the biblio, exemplars will have a > button "manage bundle"->add_to_bundle, fill in a barcode and check "add MARC link") >4 - Check on the MARC that field 461 (UNIMARC) or 773 (MARC21) is > propperly filled >5 - Remove the item from the bundle >6 - Check that the marc field is still there and remove it manually >7 - APPLY PATCH >8 - Repeat 2-5 -> the field should have been automatically removed >9 - Run tests -> should pass > >Note: as for link_marc_host, tests assume you are using MARC21 >Signed-off-by: Thibault Keromnes <thibault.keromnes@univ-paris8.fr> >--- > Koha/Biblio.pm | 34 ++++++++++++++++++++++++++++++++++ > Koha/REST/V1/Items.pm | 1 + > 2 files changed, 35 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 25e38e62c3..b72fa024bb 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -2027,6 +2027,40 @@ sub generate_marc_host_field { > return $link_field; > } > >+=head3 unlink_marc_host >+ >+ $biblio->unlink_marc_host({ host => $biblio }); >+ $biblio->unlink_marc_host({ host => $biblionumber }); >+ >+Remove the link to the parent created by link_marc_host. Expects either the biblio object or biblionumber of the host to link to. >+ >+=cut >+ >+sub unlink_marc_host { >+ my ( $self, $params ) = @_; >+ my $host_biblionumber; >+ if ( ref( $params->{host} ) eq 'Koha::Biblio' ) { >+ $host_biblionumber = $params->{host}->biblionumber; >+ } else { >+ $host_biblionumber = $params->{host}; >+ } >+ >+ my $record = $self->metadata->record; >+ my $field_number = C4::Context->preference('marcflavour') eq 'MARC21' ? '773' : '461'; >+ my @fields = $record->field($field_number); >+ >+ foreach my $field (@fields) { >+ my $subfield_biblionumber = $field->subfield('0') // q{}; >+ if ( $host_biblionumber eq $subfield_biblionumber ) { >+ $record->delete_field($field); >+ last; >+ } >+ } >+ >+ C4::Biblio::ModBiblio( $record, $self->biblionumber ); >+} >+ >+ > =head3 link_marc_host > > $biblio->link_marc_host({ field => $link_field}); >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 48468b686f..69219d1ee7 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -411,6 +411,7 @@ sub remove_from_bundle { > unless $bundle_item; > > return try { >+ $bundle_item->biblio->unlink_marc_host( { host => $item->biblio } ); > $bundle_item->remove_from_bundle; > return $c->render_resource_deleted; > } catch { >-- >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 37710
:
171832
|
171933
|
171934
|
176427
| 176428