Bug 28600 - Variable "$patron" is not available
Summary: Variable "$patron" is not available
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 18989
Blocks:
  Show dependency treegraph
 
Reported: 2021-06-18 14:16 UTC by Jonathan Druart
Modified: 2021-07-22 06:19 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.01


Attachments
Bug 28600: Resolve variable scope issue (2.40 KB, patch)
2021-06-18 18:59 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 28600: Resolve variable scope issue (2.48 KB, patch)
2021-06-21 07:59 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 28600: Resolve variable scope issue (2.57 KB, patch)
2021-06-23 14:21 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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