[Koha-bugs] [Bug 35518] New: Call to C4::Context->userenv happens before it's gets populated breaks code logic
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Dec 7 22:04:01 CET 2023
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35518
Bug ID: 35518
Summary: Call to C4::Context->userenv happens before it's gets
populated breaks code logic
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P5 - low
Component: Circulation
Assignee: koha-bugs at lists.koha-community.org
Reporter: slavashishkin at gmail.com
QA Contact: testopia at bugs.koha-community.org
CC: gmcharlt at gmail.com, kyle.m.hall at gmail.com,
nugged at gmail.com
Depends on: 17798
We getting results from `C4::Context->userenv` on line 72:
my $userenv = C4::Context->userenv;
but `C4::Context->userenv` gets populated only far below in
`get_template_and_user` call, line 142,
this means that everything that we getting further from `$userenv` is empty.
And more, because autovivification occurs for the `$userenv` at line 73:
my $branch = $userenv->{'branch'} // '';
that does not cause any visible errors, but it causes malfunctions at places
where $branch, $desk_id is used, and also where $userenv is accessed, at line
153:
if (!C4::Auth::haspermission( $userenv->{id} , { circulate =>
'force_checkout' } ) ).
To check that we have undef and it gets autovivificated, let's add some dumps
into code when we open any borrower, e.g.
/cgi-bin/koha/circ/circulation.pl?borrowernumber=19,
Let's dump $userenv before and after `$branch = $userenv->{'branch'} // '';`
line:
72 my $userenv = C4::Context->userenv;
73 use Data::Dumper;
74 warn __LINE__, ' ', Dumper($userenv);
75 my $branch = $userenv->{'branch'} // '';
76 warn __LINE__, ' ', Dumper($userenv);
this gives in server logs:
74 $VAR1 = undef;
76 $VAR1 = {};
and also to check when `C4::Context->userenv` gets its real values, let's dump
before and after the `get_template_and_user()` call at line 142 (line 145 if to
continue above dumps code):
145 warn __LINE__, ' ', Dumper([C4::Context->userenv]);
146 my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
...
153 );
154 warn __LINE__, ' ', Dumper([C4::Context->userenv]);
this gives in server logs:
145 $VAR1 = [];
154 $VAR1 = [
{
...
'id' => 'admin',
...
}
];
what depicts the whole bug.
Referenced Bugs:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17798
[Bug 17798] Checking out an item on hold for another patron prints a slip but
does not update hold
--
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
More information about the Koha-bugs
mailing list