View | Details | Raw Unified | Return to bug 40339
Collapse All | Expand All

(-)a/members/merge-patrons.pl (-1 / +17 lines)
Lines 51-56 if ( $op eq 'show' ) { Link Here
51
51
52
    if ($keeper) {
52
    if ($keeper) {
53
        try {
53
        try {
54
            # Find all guarantor relationships for the patrons to be merged
55
            my $patrons_to_merge_rs = Koha::Patrons->search({ borrowernumber => { -in => \@ids } });
56
57
            while (my $patron = $patrons_to_merge_rs->next) {
58
                # Ensure $patron is a valid Koha::Patron object
59
                if ($patron && $patron->isa('Koha::Patron')) {
60
                    my $relationships = Koha::Patron::Relationships->search({ guarantor_id => $patron->id });
61
62
                    while (my $relationship = $relationships->next) {
63
                        $relationship->guarantor_id($keeper_id);
64
                        $relationship->store;
65
                    }
66
                } else {
67
                    # If the patron is not valid, we should handle it gracefully
68
                    die "Invalid patron";
69
                }
70
            }
54
            $results = $keeper->merge_with( \@ids );
71
            $results = $keeper->merge_with( \@ids );
55
            $template->param(
72
            $template->param(
56
                keeper  => $keeper,
73
                keeper  => $keeper,
57
- 

Return to bug 40339