Bug 36139: Bug 35518 Follow-up to fix AutoSwitchPatron - clear variables
authorMichael Hafen <michael.hafen@washk12.org>
Tue, 20 Feb 2024 21:18:59 +0000 (14:18 -0700)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Fri, 22 Mar 2024 14:47:31 +0000 (15:47 +0100)
commit4d351d2c6d2452462732a2cce71565ba45ec3c05
tree2ea6515bc10a8f23fb5d891ef90205f5060cc4e6
parentb7ad3364cbf8778507f7d0dbd2a0199cbe7c0cdd
Bug 36139: Bug 35518 Follow-up to fix AutoSwitchPatron - clear variables

Bug 35518 moved some code blocks to after the call to
get_user_and_template() so that userenv would be populated before it
was needed.  This caused a couple variables to be set before the
AutoSwitchPatron block could prevent them from being set.  Which broke
AutoSwitchPatron functionality.  This clears two variable so that
AuthSwitchPatron works again.

The AutoSwitchPatron clears the $borrowernumber variable to switch
patrons. With the AuthSwitchPatron block moved, the $patron variable
still gets set, and the patron doesn't get switched.  The clears the
$patron variable too.

Also clear the barcode list.
The AutoSwitchPatron block got moved, and now the @$barcodes variable
gets filled and not cleared.  Leading to a 'Barcode not found' error
when the patron is auto switched.

Test plan:
1. Ensure AutoSwitchPatron is turned on.
2. Select the card number of two patron accounts.
3. Find the first patron in circulation.
4. Enter the second patron's card number in the item barcode field to
   switch patrons.
5. Observe the error about item barcode not existing, and the patron did
   not switch.
6. Apply patch and restart services.
7. Enter the second patron's card number in the item barcode field
   again.
8. Observe that the patron was switched with no error about an invalid
   barcode.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
circ/circulation.pl