Bug 21702: (follow-up) Simplify checks and use standard fallback behaviour
authorTomas Cohen Arazi <tomascohen@theke.io>
Sat, 27 Oct 2018 12:22:00 +0000 (09:22 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 31 Oct 2018 13:15:01 +0000 (13:15 +0000)
This patch acknowledges the fact that some checks here are done in a way
that is not standard these days. This checks are originally done
multiple times in different ways. output_and_exit_if_error should be
used.

This implies a minor behaviour change: if the passed (in the URL)
borrowernumber doesn't exist, it sends the user to a 'Patron doesn't
exist page' instead of the circulation page for the borrowernumber.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

members/mancredit.pl

index 49ab8a4..5000fb2 100755 (executable)
@@ -55,10 +55,9 @@ my $logged_in_user = Koha::Patrons->find($loggedinuser) or die "Not logged in";
 my $borrowernumber = $input->param('borrowernumber');
 my $patron         = Koha::Patrons->find($borrowernumber);
 
-unless ( $patron ) {
-    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
-    exit;
-}
+output_and_exit_if_error( $input, $cookie, $template,
+    { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
+
 my $add = $input->param('add');
 
 if ($add){
@@ -94,7 +93,6 @@ if ($add){
     print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
 
 } else {
-    output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
 
     if (C4::Context->preference('ExtendedPatronAttributes')) {
         my $attributes = GetBorrowerAttributes($borrowernumber);