Bug 28600

Summary: Variable "$patron" is not available
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: OPACAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: major    
Priority: P5 - low CC: dcook, fridolin.somers, kyle, m.de.rooy
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.01
Bug Depends on: 18989    
Bug Blocks:    
Attachments: Bug 28600: Resolve variable scope issue
Bug 28600: Resolve variable scope issue
Bug 28600: Resolve variable scope issue

Description Jonathan Druart 2021-06-18 14:16:47 UTC
In the logs:
Variable "$patron" is not available at /kohadevbox/koha/opac/opac-detail.pl line 282

Coming from 
  commit 8de3d9a95f2f3a01b5ed309805d81c698ac8e550
  Bug 18989: (QA follow-up) Make controllers use Koha::Biblio->hidden_in_opac

-            'category'  => $borcat
+            'category'  => ($patron) ? $patron->categorycode : q{}

It's in a sub, and patron is declared outside.
Comment 1 Tomás Cohen Arazi 2021-06-18 18:18:11 UTC
Ha, $borcat (which I replaced with $patron) was defined as (our)

-our $borcat= q{};
-if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
-    $borcat = $patron ? $patron->categorycode : q{};
-}

I guess I overlooked it. Patch coming.
Comment 2 Tomás Cohen Arazi 2021-06-18 18:59:27 UTC
Created attachment 122171 [details] [review]
Bug 28600: Resolve variable scope issue

This patch fixes a scope issue. Originally, a variable declared as

our $borcat

was replaced by

my $patron

This patch makes the method not rely on global variables, but have a
parameter for the patron, and thus things are clearer.

To test:
1. Open the OPAC detail page for a record
=> FAIL: The logs show some errors about the $patron variable not
available in the scope
2. Apply this patch
3. Repeat 1
=> SUCCESS: No errors
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Jonathan Druart 2021-06-21 07:59:02 UTC
Created attachment 122207 [details] [review]
Bug 28600: Resolve variable scope issue

This patch fixes a scope issue. Originally, a variable declared as

our $borcat

was replaced by

my $patron

This patch makes the method not rely on global variables, but have a
parameter for the patron, and thus things are clearer.

To test:
1. Open the OPAC detail page for a record
=> FAIL: The logs show some errors about the $patron variable not
available in the scope
2. Apply this patch
3. Repeat 1
=> SUCCESS: No errors
4. Sign off :-D

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 4 Marcel de Rooy 2021-06-23 14:21:33 UTC
Created attachment 122338 [details] [review]
Bug 28600: Resolve variable scope issue

This patch fixes a scope issue. Originally, a variable declared as

our $borcat

was replaced by

my $patron

This patch makes the method not rely on global variables, but have a
parameter for the patron, and thus things are clearer.

To test:
1. Open the OPAC detail page for a record
=> FAIL: The logs show some errors about the $patron variable not
available in the scope
2. Apply this patch
3. Repeat 1
=> SUCCESS: No errors
4. Sign off :-D

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Jonathan Druart 2021-06-24 09:54:23 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall 2021-06-25 13:31:12 UTC
(In reply to Jonathan Druart from comment #5)
> Pushed to master for 21.11, thanks to everybody involved!

Pushed to 21.05.x for 21.05.01
Comment 7 Fridolin Somers 2021-07-10 01:31:07 UTC
Depends on Bug 18989 not is 20.11.x