From 4f533776c609463a88db560f447874f351e8d131 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 14 Jan 2021 09:47:46 -0500 Subject: [PATCH] Bug 26352: Switch from using call() to call_recursive() Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/SIP/Sip/MsgType.pm | 16 ++++++++-------- Koha/Patron.pm | 4 ++-- circ/circulation.pl | 4 ++-- members/memberentry.pl | 2 +- opac/sco/sco-main.pl | 2 +- .../Koha/Plugins/Barcode_transform_hooks.t | 1 + 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 45f9e8fac6..7a1651a2fc 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -521,7 +521,7 @@ sub handle_checkout { $fields = $self->{fields}; $patron_id = $fields->{ (FID_PATRON_ID) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); $item_id = $fields->{ (FID_ITEM_ID) }; my $fee_ack = $fields->{ (FID_FEE_ACK) }; @@ -743,7 +743,7 @@ sub handle_block_patron { $patron_id = $fields->{ (FID_PATRON_ID) }; $terminal_pwd = $fields->{ (FID_TERMINAL_PWD) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); # Terminal passwords are different from account login # passwords, but I have no idea what to do with them. So, @@ -969,7 +969,7 @@ sub handle_patron_info { $start = $fields->{ (FID_START_ITEM) }; $end = $fields->{ (FID_END_ITEM) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); $patron = $ils->find_patron($patron_id); @@ -1128,7 +1128,7 @@ sub handle_fee_paid { $fee_id = $fields->{ (FID_FEE_ID) }; $trans_id = $fields->{ (FID_TRANSACTION_ID) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); $ils->check_inst_id( $inst_id, "handle_fee_paid" ); @@ -1332,7 +1332,7 @@ sub handle_patron_enable { $patron_id = $fields->{ (FID_PATRON_ID) }; $patron_pwd = $fields->{ (FID_PATRON_PWD) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); siplog( "LOG_DEBUG", "handle_patron_enable: patron_id: '%s', patron_pwd: '%s'", $patron_id, $patron_pwd ); @@ -1397,7 +1397,7 @@ sub handle_hold { $title_id = $fields->{ (FID_TITLE_ID) } || ''; $fee_ack = $fields->{ (FID_FEE_ACK) } || 'N'; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); if ( $hold_mode eq '+' ) { $status = $ils->add_hold( $patron_id, $patron_pwd, $item_id, $title_id, $expiry_date, $pickup_locn, $hold_type, $fee_ack ); @@ -1464,7 +1464,7 @@ sub handle_renew { $item_props = $fields->{ (FID_ITEM_PROPS) }; $fee_ack = $fields->{ (FID_FEE_ACK) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); $status = $ils->renew( $patron_id, $patron_pwd, $item_id, $title_id, $no_block, $nb_due_date, $third_party, $item_props, $fee_ack ); @@ -1547,7 +1547,7 @@ sub handle_renew_all { $terminal_pwd = $fields->{ (FID_TERMINAL_PWD) }; $fee_ack = $fields->{ (FID_FEE_ACK) }; - ($patron_id) = Koha::Plugins->call('patron_barcode_transform', $patron_id ) || $patron_id; + ($patron_id) = Koha::Plugins->call_recursive('patron_barcode_transform', $patron_id ); $status = $ils->renew_all( $patron_id, $patron_pwd, $fee_ack ); diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 0eed3de4ff..c1a86a9da0 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -112,7 +112,7 @@ Autogenerate next cardnumber from highest value found in database sub fixup_cardnumber { my ( $self ) = @_; - my ( $max ) = Koha::Plugins->call( 'patron_barcode_transform', $self->cardnumber ) || undef; + my ( $max ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $self->cardnumber ); $max ||= Koha::Patrons->search({ cardnumber => {-regexp => '^-?[0-9]+$'} @@ -201,7 +201,7 @@ sub store { $self->trim_whitespaces; - my ( $new_cardnumber ) = Koha::Plugins->call( 'patron_barcode_transform', $self->cardnumber ) || $self->cardnumber; + my ( $new_cardnumber ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $self->cardnumber ); $self->cardnumber( $new_cardnumber ); # Set surname to uppercase if uppercasesurname is true diff --git a/circ/circulation.pl b/circ/circulation.pl index 4bbb44479e..4f6607b9e2 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -75,7 +75,7 @@ my $autoswitched; my $borrowernumber = $query->param('borrowernumber'); if (C4::Context->preference("AutoSwitchPatron") && $barcode) { - my ( $new_barcode ) = Koha::Plugins->call( 'patron_barcode_transform', $findborrower ) || $findborrower; + my ( $new_barcode ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $findborrower ); if (Koha::Patrons->search( { cardnumber => $new_barcode} )->count() > 0) { $findborrower = $barcode; undef $barcode; @@ -221,7 +221,7 @@ if ( @$barcodes == 0 && $charges eq 'yes' ) { # my $message; if ($findborrower) { - ( $findborrower ) = Koha::Plugins->call( 'patron_barcode_transform', $findborrower ) || $findborrower; + ( $findborrower ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $findborrower ); my $patron = Koha::Patrons->find( { cardnumber => $findborrower } ); if ( $patron ) { $borrowernumber = $patron->borrowernumber; diff --git a/members/memberentry.pl b/members/memberentry.pl index 57feaa3221..d85e55e54a 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -325,7 +325,7 @@ if ($op eq 'save' || $op eq 'insert'){ # If the cardnumber is blank, treat it as null. $newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/; - my ( $new_barcode ) = Koha::Plugins->call( 'patron_barcode_transform', $newdata{'cardnumber'} ) || $newdata{'cardnumber'}; + my ( $new_barcode ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $newdata{'cardnumber'} ); $newdata{'cardnumber'} = $new_barcode; if (my $error_code = checkcardnumber( $newdata{cardnumber}, $borrowernumber )){ diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index 1199d2a093..df3d619e57 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -120,7 +120,7 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { my ( $borrower, $patron ); if ( $patronid ) { - ( $patronid ) = Koha::Plugins->call( 'patron_barcode_transform', $patronid ) || $patronid; + ( $patronid ) = Koha::Plugins->call_recursive( 'patron_barcode_transform', $patronid ); $patron = Koha::Patrons->find( { cardnumber => $patronid } ); $borrower = $patron->unblessed if $patron; } diff --git a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t index 7f3682b993..889dcf500b 100755 --- a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t +++ b/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t @@ -48,6 +48,7 @@ subtest '() hook tests' => sub { my $plugins = Koha::Plugins->new; $plugins->InstallPlugins; + C4::Context->dbh->do("DELETE FROM plugin_methods WHERE plugin_class LIKE '%TestBarcodes%'"); my $plugin = Koha::Plugin::Test->new->enable; -- 2.39.5