Bugzilla – Attachment 190334 Details for
Bug 40339
Merge patrons causes guarantees without guarantors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40339: add guarantees to target patron when merging patrons
0001-Bug-40339-add-guarantees-to-target-patron-when-mergi.patch (text/plain), 1.99 KB, created by
Olli Kautonen
on 2025-12-09 08:15:57 UTC
(
hide
)
Description:
Bug 40339: add guarantees to target patron when merging patrons
Filename:
MIME Type:
Creator:
Olli Kautonen
Created:
2025-12-09 08:15:57 UTC
Size:
1.99 KB
patch
obsolete
>From 8ede54c33e493bccb02dfa09edaddc45f2d56941 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Johanna=20R=C3=A4is=C3=A4?= <johanna.raisa@gmail.com> >Date: Mon, 11 Aug 2025 12:05:30 +0300 >Subject: [PATCH] Bug 40339: add guarantees to target patron when merging > patrons > >This patch adds the guarantees from the source patron to the >target patron when merging patrons. > >Test plan: >1. Create two patrons with different guarantees. >2. Merge the source patron into the target patron. >3. See that the target patron does not have the source patron's > guarantees. >4. Apply this patch. >5. Repeat the merge. >6. See that the target patron now has the source patron's guarantees. > >Sponsored-by: Koha-Suomi Oy >--- > members/merge-patrons.pl | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > >diff --git a/members/merge-patrons.pl b/members/merge-patrons.pl >index cb10f2fcbb..cbeb7daf3f 100755 >--- a/members/merge-patrons.pl >+++ b/members/merge-patrons.pl >@@ -51,6 +51,23 @@ if ( $op eq 'show' ) { > > if ($keeper) { > try { >+ # Find all guarantor relationships for the patrons to be merged >+ my $patrons_to_merge_rs = Koha::Patrons->search({ borrowernumber => { -in => \@ids } }); >+ >+ while (my $patron = $patrons_to_merge_rs->next) { >+ # Ensure $patron is a valid Koha::Patron object >+ if ($patron && $patron->isa('Koha::Patron')) { >+ my $relationships = Koha::Patron::Relationships->search({ guarantor_id => $patron->id }); >+ >+ while (my $relationship = $relationships->next) { >+ $relationship->guarantor_id($keeper_id); >+ $relationship->store; >+ } >+ } else { >+ # If the patron is not valid, we should handle it gracefully >+ die "Invalid patron"; >+ } >+ } > $results = $keeper->merge_with( \@ids ); > $template->param( > keeper => $keeper, >-- >2.34.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 40339
: 190334