From 216c861273b7071e7ccb77a87de4624418dc6ebb 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 --- 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 f651bd488d..749191bcba 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -520,7 +520,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) }; @@ -742,7 +742,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, @@ -968,7 +968,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); @@ -1127,7 +1127,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" ); @@ -1325,7 +1325,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 ); @@ -1390,7 +1390,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 ); @@ -1457,7 +1457,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 ); @@ -1540,7 +1540,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 ffef93cb74..8b33638ee7 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 e694fe297b..9cd505743b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -81,7 +81,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; @@ -227,7 +227,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 083ff5acfa..34ff3d86ff 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -333,7 +333,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},$newdata{borrowernumber})){ diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index d840592c03..e16770c11d 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -124,7 +124,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.20.1