View | Details | Raw Unified | Return to bug 36367
Collapse All | Expand All

(-)a/C4/Auth.pm (-9 / +5 lines)
Lines 933-939 sub checkauth { Link Here
933
                $session->delete();
933
                $session->delete();
934
                $session->flush;
934
                $session->flush;
935
                $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie );
935
                $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie );
936
                C4::Context::_unset_userenv($sessionID);
936
                C4::Context::unset_userenv();
937
                $sessionID = undef;
937
                $sessionID = undef;
938
                undef $userid; # IMPORTANT: this assures us a new session in code below
938
                undef $userid; # IMPORTANT: this assures us a new session in code below
939
                $auth_state = 'failed';
939
                $auth_state = 'failed';
Lines 982-988 sub checkauth { Link Here
982
            $session->delete();
982
            $session->delete();
983
            $session->flush;
983
            $session->flush;
984
        }
984
        }
985
        C4::Context::_unset_userenv($sessionID);
985
        C4::Context::unset_userenv();
986
        $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie );
986
        $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie );
987
987
988
        if ($cas and $caslogout) {
988
        if ($cas and $caslogout) {
Lines 1012-1018 sub checkauth { Link Here
1012
        }
1012
        }
1013
1013
1014
        $sessionID = $session->id;
1014
        $sessionID = $session->id;
1015
        C4::Context->_new_userenv($sessionID);
1016
        $cookie = $cookie_mgr->replace_in_list( $cookie, $query->cookie(
1015
        $cookie = $cookie_mgr->replace_in_list( $cookie, $query->cookie(
1017
            -name     => 'CGISESSID',
1016
            -name     => 'CGISESSID',
1018
            -value    => $sessionID,
1017
            -value    => $sessionID,
Lines 1158-1164 sub checkauth { Link Here
1158
                    # although we do present an authorization failure. (Yes, the
1157
                    # although we do present an authorization failure. (Yes, the
1159
                    # authentication was actually correct.)
1158
                    # authentication was actually correct.)
1160
                    $info{'nopermission'} = 1;
1159
                    $info{'nopermission'} = 1;
1161
                    C4::Context::_unset_userenv($sessionID);
1160
                    C4::Context::unset_userenv();
1162
                }
1161
                }
1163
                my ( $borrowernumber, $firstname, $surname, $userflags,
1162
                my ( $borrowernumber, $firstname, $surname, $userflags,
1164
                    $branchcode, $branchname, $emailaddress, $desk_id,
1163
                    $branchcode, $branchname, $emailaddress, $desk_id,
Lines 1289-1295 sub checkauth { Link Here
1289
            else {
1288
            else {
1290
                if ($userid) {
1289
                if ($userid) {
1291
                    $info{'invalid_username_or_password'} = 1;
1290
                    $info{'invalid_username_or_password'} = 1;
1292
                    C4::Context::_unset_userenv($sessionID);
1291
                    C4::Context::unset_userenv();
1293
                }
1292
                }
1294
                $session->param( 'lasttime', time() );
1293
                $session->param( 'lasttime', time() );
1295
                $session->param( 'ip',       $session->remote_addr() );
1294
                $session->param( 'ip',       $session->remote_addr() );
Lines 1650-1656 sub check_api_auth { Link Here
1650
            return ( "failed", undef, undef ) unless $session;
1649
            return ( "failed", undef, undef ) unless $session;
1651
1650
1652
            my $sessionID = $session->id;
1651
            my $sessionID = $session->id;
1653
            C4::Context->_new_userenv($sessionID);
1654
            my $cookie = $query->cookie(
1652
            my $cookie = $query->cookie(
1655
                -name     => 'CGISESSID',
1653
                -name     => 'CGISESSID',
1656
                -value    => $sessionID,
1654
                -value    => $sessionID,
Lines 1814-1820 sub check_cookie_auth { Link Here
1814
    unless ( $sessionID ) {
1812
    unless ( $sessionID ) {
1815
        return ( "failed", undef );
1813
        return ( "failed", undef );
1816
    }
1814
    }
1817
    C4::Context::_unset_userenv($sessionID); # remove old userenv first
1815
    C4::Context::unset_userenv();
1818
    my $session   = get_session($sessionID);
1816
    my $session   = get_session($sessionID);
1819
    if ($session) {
1817
    if ($session) {
1820
        my $userid   = $session->param('id');
1818
        my $userid   = $session->param('id');
Lines 1851-1857 sub check_cookie_auth { Link Here
1851
            return ("password_expired", undef ) if $patron->password_expired;
1849
            return ("password_expired", undef ) if $patron->password_expired;
1852
            my $flags = defined($flagsrequired) ? haspermission( $userid, $flagsrequired ) : 1;
1850
            my $flags = defined($flagsrequired) ? haspermission( $userid, $flagsrequired ) : 1;
1853
            if ($flags) {
1851
            if ($flags) {
1854
                C4::Context->_new_userenv($sessionID);
1855
                if ( !C4::Context->interface ) {
1852
                if ( !C4::Context->interface ) {
1856
                    # No need to override the interface, most often set by get_template_and_user
1853
                    # No need to override the interface, most often set by get_template_and_user
1857
                    C4::Context->interface( $session->param('interface') );
1854
                    C4::Context->interface( $session->param('interface') );
Lines 1881-1887 sub check_cookie_auth { Link Here
1881
            }
1878
            }
1882
1879
1883
        } else {
1880
        } else {
1884
            C4::Context->_new_userenv($sessionID);
1885
            C4::Context->interface($session->param('interface'));
1881
            C4::Context->interface($session->param('interface'));
1886
            C4::Context->set_userenv( undef, q{} );
1882
            C4::Context->set_userenv( undef, q{} );
1887
            return ( "anon", $session );
1883
            return ( "anon", $session );
(-)a/C4/Context.pm (-41 / +7 lines)
Lines 182-188 sub new { Link Here
182
182
183
    $self->{"Zconn"} = undef;    # Zebra Connections
183
    $self->{"Zconn"} = undef;    # Zebra Connections
184
    $self->{"userenv"} = undef;        # User env
184
    $self->{"userenv"} = undef;        # User env
185
    $self->{"activeuser"} = undef;        # current active user
186
    $self->{"shelves"} = undef;
185
    $self->{"shelves"} = undef;
187
    $self->{tz} = undef; # local timezone object
186
    $self->{tz} = undef; # local timezone object
188
187
Lines 757-775 sub restore_dbh Link Here
757
756
758
Retrieves a hash for user environment variables.
757
Retrieves a hash for user environment variables.
759
758
760
This hash shall be cached for future use: if you call
761
C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
762
763
=cut
759
=cut
764
760
765
#'
766
sub userenv {
761
sub userenv {
767
    my $var = $context->{"activeuser"};
762
    return $context->{userenv};
768
    if (defined $var and defined $context->{"userenv"}->{$var}) {
769
        return $context->{"userenv"}->{$var};
770
    } else {
771
        return;
772
    }
773
}
763
}
774
764
775
=head2 set_userenv
765
=head2 set_userenv
Lines 797-803 sub set_userenv { Link Here
797
        $register_id,  $register_name
787
        $register_id,  $register_name
798
    ) = @_;
788
    ) = @_;
799
789
800
    my $var=$context->{"activeuser"} || '';
801
    my $cell = {
790
    my $cell = {
802
        "number"     => $usernum,
791
        "number"     => $usernum,
803
        "id"         => $userid,
792
        "id"         => $userid,
Lines 816-859 sub set_userenv { Link Here
816
        "register_id"   => $register_id,
805
        "register_id"   => $register_id,
817
        "register_name" => $register_name
806
        "register_name" => $register_name
818
    };
807
    };
819
    $context->{userenv}->{$var} = $cell;
808
    $context->{userenv} = $cell;
820
    return $cell;
809
    return $cell;
821
}
810
}
822
811
823
=head2 _new_userenv
812
=head2 unset_userenv
824
825
  C4::Context->_new_userenv($session);  # FIXME: This calling style is wrong for what looks like an _internal function
826
827
Builds a hash for user environment variables.
828
829
This hash shall be cached for future use: if you call
830
C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
831
832
_new_userenv is called in Auth.pm
833
834
=cut
835
836
#'
837
sub _new_userenv
838
{
839
    shift;  # Useless except it compensates for bad calling style
840
    my ($sessionID)= @_;
841
     $context->{"activeuser"}=$sessionID;
842
}
843
844
=head2 _unset_userenv
845
813
846
  C4::Context->_unset_userenv;
814
  C4::Context->unset_userenv;
847
815
848
Destroys the hash for activeuser user environment variables.
816
Destroys user environment variables.
849
817
850
=cut
818
=cut
851
819
852
#'
820
sub unset_userenv
853
854
sub _unset_userenv
855
{
821
{
856
    delete $context->{activeuser};
822
    $context->{userenv} = {};
857
}
823
}
858
824
859
825
(-)a/C4/InstallAuth.pm (-4 / +2 lines)
Lines 252-258 sub checkauth { Link Here
252
    my $session = Koha::Session->get_session( { sessionID => $sessionID, storage_method => 'file' } );
252
    my $session = Koha::Session->get_session( { sessionID => $sessionID, storage_method => 'file' } );
253
253
254
    if ( $session ) {
254
    if ( $session ) {
255
        C4::Context->_new_userenv($sessionID);
256
        if ( $session->param('cardnumber') ) {
255
        if ( $session->param('cardnumber') ) {
257
            C4::Context->set_userenv(
256
            C4::Context->set_userenv(
258
                $session->param('number'),
257
                $session->param('number'),
Lines 279-285 sub checkauth { Link Here
279
278
280
    if ($logout || !$session) {
279
    if ($logout || !$session) {
281
        # voluntary logout the user
280
        # voluntary logout the user
282
        C4::Context->_unset_userenv($sessionID);
281
        C4::Context->unset_userenv();
283
        $session = Koha::Session->get_session( { storage_method => 'file' } );
282
        $session = Koha::Session->get_session( { storage_method => 'file' } );
284
    }
283
    }
285
284
Lines 288-294 sub checkauth { Link Here
288
    unless ($userid) {
287
    unless ($userid) {
289
        $userid = $query->param('login_userid');
288
        $userid = $query->param('login_userid');
290
        my $password = $query->param('login_password');
289
        my $password = $query->param('login_password');
291
        C4::Context->_new_userenv($sessionID);
292
        my ( $return, $cardnumber ) = checkpw( $userid, $password );
290
        my ( $return, $cardnumber ) = checkpw( $userid, $password );
293
        if ($return) {
291
        if ($return) {
294
            $loggedin = 1;
292
            $loggedin = 1;
Lines 334-340 sub checkauth { Link Here
334
        else {
332
        else {
335
            if ($userid) {
333
            if ($userid) {
336
                $info{'invalid_username_or_password'} = 1;
334
                $info{'invalid_username_or_password'} = 1;
337
                C4::Context->_unset_userenv($sessionID);
335
                C4::Context->unset_userenv();
338
            }
336
            }
339
        }
337
        }
340
    }
338
    }
(-)a/Koha/BackgroundJob.pm (-1 lines)
Lines 170-176 sub process { Link Here
170
170
171
    if ( $self->context ) {
171
    if ( $self->context ) {
172
        my $context = $self->json->decode($self->context);
172
        my $context = $self->json->decode($self->context);
173
        C4::Context->_new_userenv(-1);
174
        C4::Context->interface( $context->{interface} );
173
        C4::Context->interface( $context->{interface} );
175
        C4::Context->set_userenv(
174
        C4::Context->set_userenv(
176
            $context->{number},       $context->{id},
175
            $context->{number},       $context->{id},
(-)a/Koha/Middleware/UserEnv.pm (-1 / +1 lines)
Lines 22-28 sub call { Link Here
22
22
23
    my $req = Plack::Request->new($env);
23
    my $req = Plack::Request->new($env);
24
24
25
    C4::Context->_unset_userenv;
25
    C4::Context->unset_userenv;
26
26
27
    return $self->app->($env);
27
    return $self->app->($env);
28
}
28
}
(-)a/Koha/REST/V1/Auth.pm (-1 / +1 lines)
Lines 566-572 sub _set_userenv { Link Here
566
        $THE_library = $patron->library;
566
        $THE_library = $patron->library;
567
    }
567
    }
568
568
569
    C4::Context->_new_userenv( $patron->borrowernumber );
569
    C4::Context->new_userenv();
570
    C4::Context->set_userenv(
570
    C4::Context->set_userenv(
571
        $patron->borrowernumber,  # number,
571
        $patron->borrowernumber,  # number,
572
        $patron->userid,          # userid,
572
        $patron->userid,          # userid,
(-)a/Koha/Script.pm (-2 lines)
Lines 46-56 sub import { Link Here
46
    my $class = shift;
46
    my $class = shift;
47
    my @flags = @_;
47
    my @flags = @_;
48
48
49
    C4::Context->_new_userenv(1);
50
    if ( ( $flags[0] || '' ) eq '-cron' ) {
49
    if ( ( $flags[0] || '' ) eq '-cron' ) {
51
50
52
        # Set userenv
51
        # Set userenv
53
        C4::Context->_new_userenv(1);
54
        C4::Context->set_userenv(
52
        C4::Context->set_userenv(
55
            undef, undef, undef, 'CRON', 'CRON',
53
            undef, undef, undef, 'CRON', 'CRON',
56
            undef, undef, undef, undef,  undef
54
            undef, undef, undef, undef,  undef
(-)a/opac/ilsdi.pl (-1 lines)
Lines 128-134 unless ( $cgi->param('service') ) { Link Here
128
}
128
}
129
129
130
# Set the userenv
130
# Set the userenv
131
C4::Context->_new_userenv( 'ILSDI_'.time() );
132
C4::Context->set_userenv(
131
C4::Context->set_userenv(
133
    undef, undef, undef, 'ILSDI', 'ILSDI',
132
    undef, undef, undef, 'ILSDI', 'ILSDI',
134
    undef, undef, undef, undef, undef,
133
    undef, undef, undef, undef, undef,
(-)a/t/Token.t (-3 lines)
Lines 27-33 use Time::HiRes qw|usleep|; Link Here
27
use C4::Context;
27
use C4::Context;
28
use Koha::Token;
28
use Koha::Token;
29
29
30
C4::Context->_new_userenv('DUMMY SESSION');
31
C4::Context->set_userenv(0,42,0,'firstname','surname', 'CPL', 'Library 1', 0, '');
30
C4::Context->set_userenv(0,42,0,'firstname','surname', 'CPL', 'Library 1', 0, '');
32
31
33
my $tokenizer = Koha::Token->new;
32
my $tokenizer = Koha::Token->new;
Lines 114-127 subtest 'testing _add_default_csrf_params with/without userenv (bug 27849)' => s Link Here
114
    is( $result->{id}, 'anonymous_567', 'Check userid' );
113
    is( $result->{id}, 'anonymous_567', 'Check userid' );
115
114
116
    # Clear userenv
115
    # Clear userenv
117
    C4::Context::_unset_userenv('DUMMY SESSION');
118
    is( C4::Context::userenv, undef, 'No userenv anymore' );
116
    is( C4::Context::userenv, undef, 'No userenv anymore' );
119
    $result = Koha::Token::_add_default_csrf_params({}); # pass no session_id
117
    $result = Koha::Token::_add_default_csrf_params({}); # pass no session_id
120
    is( $result->{session_id}, Koha::Token::DEFA_SESSION_ID, 'Check session id' );
118
    is( $result->{session_id}, Koha::Token::DEFA_SESSION_ID, 'Check session id' );
121
    is( $result->{id}, Koha::Token::DEFA_SESSION_USERID. '_'. $result->{session_id}, 'Check userid' );
119
    is( $result->{id}, Koha::Token::DEFA_SESSION_USERID. '_'. $result->{session_id}, 'Check userid' );
122
120
123
    # Empty anonymous userenv (see C4::Auth::check_cookie_auth)
121
    # Empty anonymous userenv (see C4::Auth::check_cookie_auth)
124
    C4::Context->_new_userenv('ANON SESSION');
125
    C4::Context->set_userenv( undef, q{} );
122
    C4::Context->set_userenv( undef, q{} );
126
    ok( C4::Context->userenv, "Userenv exists" );
123
    ok( C4::Context->userenv, "Userenv exists" );
127
    $result = Koha::Token::_add_default_csrf_params( {} );    # pass no session_id
124
    $result = Koha::Token::_add_default_csrf_params( {} );    # pass no session_id
(-)a/t/db_dependent/Auth.t (-6 / +1 lines)
Lines 199-205 subtest 'checkauth() tests' => sub { Link Here
199
        $session->param( 'interface', 'intranet' );
199
        $session->param( 'interface', 'intranet' );
200
        $session->flush;
200
        $session->flush;
201
        my $sessionID = $session->id;
201
        my $sessionID = $session->id;
202
        C4::Context->_new_userenv($sessionID);
203
202
204
        my ($return) =
203
        my ($return) =
205
            C4::Auth::check_cookie_auth( $sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } );
204
            C4::Auth::check_cookie_auth( $sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } );
Lines 233-239 subtest 'checkauth() tests' => sub { Link Here
233
        $session->param( 'interface',    'opac' );
232
        $session->param( 'interface',    'opac' );
234
        $session->flush;
233
        $session->flush;
235
        my $previous_sessionID = $session->id;
234
        my $previous_sessionID = $session->id;
236
        C4::Context->_new_userenv($previous_sessionID);
237
235
238
        my ( $return ) = C4::Auth::check_cookie_auth( $previous_sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } );
236
        my ( $return ) = C4::Auth::check_cookie_auth( $previous_sessionID, undef, { skip_version_check => 1, remote_addr => '1.2.3.4' } );
239
        is( $return, 'ok', 'Former session in shape now' );
237
        is( $return, 'ok', 'Former session in shape now' );
Lines 262-268 subtest 'checkauth() tests' => sub { Link Here
262
        $session->param( 'interface',    'intranet' );
260
        $session->param( 'interface',    'intranet' );
263
        $session->flush;
261
        $session->flush;
264
        $previous_sessionID = $session->id;
262
        $previous_sessionID = $session->id;
265
        C4::Context->_new_userenv($previous_sessionID);
266
        $cgi->param( -name => 'login_userid',             -value => $patron2->userid );
263
        $cgi->param( -name => 'login_userid',             -value => $patron2->userid );
267
        $cgi->param( -name => 'login_password',           -value => $password );
264
        $cgi->param( -name => 'login_password',           -value => $password );
268
        $cgi->param( -name => 'koha_login_context', -value => 1 );
265
        $cgi->param( -name => 'koha_login_context', -value => 1 );
Lines 417-423 subtest 'checkauth() tests' => sub { Link Here
417
        is( $sesh->param('branch'), $branch->branchcode, "If user is superlibrarian, they should be able to choose a branch" );
414
        is( $sesh->param('branch'), $branch->branchcode, "If user is superlibrarian, they should be able to choose a branch" );
418
415
419
    };
416
    };
420
    C4::Context->_new_userenv; # For next tests
421
};
417
};
422
418
423
subtest 'no_set_userenv parameter tests' => sub {
419
subtest 'no_set_userenv parameter tests' => sub {
Lines 430-437 subtest 'no_set_userenv parameter tests' => sub { Link Here
430
    my $password = set_weak_password($patron);
426
    my $password = set_weak_password($patron);
431
427
432
    ok( checkpw( $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' );
428
    ok( checkpw( $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' );
429
    C4::Context->unset_userenv;
433
    is( C4::Context->userenv, undef, 'Userenv should be undef as required' );
430
    is( C4::Context->userenv, undef, 'Userenv should be undef as required' );
434
    C4::Context->_new_userenv('DUMMY SESSION');
435
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Library 1', 0, '', '');
431
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Library 1', 0, '', '');
436
    is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv gives correct branch' );
432
    is( C4::Context->userenv->{branch}, $library->branchcode, 'Userenv gives correct branch' );
437
    ok( checkpw( $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' );
433
    ok( checkpw( $patron->userid, $password, undef, undef, 1 ), 'checkpw returns true' );
Lines 940-946 subtest 'Userenv clearing in check_cookie_auth' => sub { Link Here
940
    is( C4::Context->userenv, undef, 'Environment should be cleared too' );
936
    is( C4::Context->userenv, undef, 'Environment should be cleared too' );
941
937
942
    # Show that we clear the userenv again: set up env and check deleted session
938
    # Show that we clear the userenv again: set up env and check deleted session
943
    C4::Context->_new_userenv( $sessionID );
944
    C4::Context->set_userenv; # empty
939
    C4::Context->set_userenv; # empty
945
    is( defined C4::Context->userenv, 1, 'There should be an empty userenv again' );
940
    is( defined C4::Context->userenv, 1, 'There should be an empty userenv again' );
946
    ( $auth_status, $session) = C4::Auth::check_cookie_auth( $sessionID );
941
    ( $auth_status, $session) = C4::Auth::check_cookie_auth( $sessionID );
(-)a/t/db_dependent/Koha/BackgroundJob.t (-1 lines)
Lines 229-235 subtest 'process tests' => sub { Link Here
229
        { size => 10, a => 'aaa', b => 'bbb' } );
229
        { size => 10, a => 'aaa', b => 'bbb' } );
230
    my $job    = Koha::BackgroundJobs->find($job_id);
230
    my $job    = Koha::BackgroundJobs->find($job_id);
231
231
232
    C4::Context->_new_userenv(-1);
233
    C4::Context->interface('opac');
232
    C4::Context->interface('opac');
234
    is( C4::Context->userenv, undef, "Userenv unset prior to calling process");
233
    is( C4::Context->userenv, undef, "Userenv unset prior to calling process");
235
    is( C4::Context->interface, 'opac', "Interface set to opac prior to calling process");
234
    is( C4::Context->interface, 'opac', "Interface set to opac prior to calling process");
(-)a/t/db_dependent/Koha/Items.t (-1 / +1 lines)
Lines 1317-1323 subtest 'store' => sub { Link Here
1317
            C4::Circulation::LostItem( $item->itemnumber, 1 );
1317
            C4::Circulation::LostItem( $item->itemnumber, 1 );
1318
1318
1319
            # Unset the userenv
1319
            # Unset the userenv
1320
            C4::Context->_new_userenv(undef);
1320
            C4::Context->unset_userenv();
1321
1321
1322
            # Simluate item marked as found
1322
            # Simluate item marked as found
1323
            $item->itemlost(0)->store;
1323
            $item->itemlost(0)->store;
(-)a/t/db_dependent/Koha/Reviews.t (-1 lines)
Lines 70-76 is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id Link Here
70
70
71
subtest 'search_limited' => sub {
71
subtest 'search_limited' => sub {
72
    plan tests => 2;
72
    plan tests => 2;
73
    C4::Context->_new_userenv('xxx');
74
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store;
73
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store;
75
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store;
74
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store;
76
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron_1->branchcode })->store();
75
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron_1->branchcode })->store();
(-)a/t/db_dependent/Koha/Template/Plugin/Registers.t (-2 / +2 lines)
Lines 45-51 subtest 'session_register_id' => sub { Link Here
45
        '1', "Returns the register id when set in the userenv" );
45
        '1', "Returns the register id when set in the userenv" );
46
46
47
    # Unset the userenv
47
    # Unset the userenv
48
    C4::Context->_new_userenv(undef);
48
    C4::Context->unset_userenv();
49
};
49
};
50
50
51
subtest 'session_register_name' => sub {
51
subtest 'session_register_name' => sub {
Lines 61-67 subtest 'session_register_name' => sub { Link Here
61
        'Register One', "Returns the register name when set in the userenv" );
61
        'Register One', "Returns the register name when set in the userenv" );
62
62
63
    # Unset the userenv
63
    # Unset the userenv
64
    C4::Context->_new_userenv(undef);
64
    C4::Context->unset_userenv();
65
};
65
};
66
66
67
subtest 'all() tests' => sub {
67
subtest 'all() tests' => sub {
(-)a/t/db_dependent/Patron/Borrower_Discharge.t (-1 lines)
Lines 47-53 my $library = $builder->build({ source => 'Branch' }); Link Here
47
my $another_library = $builder->build({ source => 'Branch' });
47
my $another_library = $builder->build({ source => 'Branch' });
48
my $itemtype        = $builder->build({ source => 'Itemtype' })->{itemtype};
48
my $itemtype        = $builder->build({ source => 'Itemtype' })->{itemtype};
49
49
50
C4::Context->_new_userenv('xxx');
51
my $patron = $builder->build_object({
50
my $patron = $builder->build_object({
52
    class => 'Koha::Patrons',
51
    class => 'Koha::Patrons',
53
    value => {
52
    value => {
(-)a/t/lib/Mocks.pm (-3 lines)
Lines 119-126 Also, some sane defaults are set if no parameters are passed. Link Here
119
sub mock_userenv {
119
sub mock_userenv {
120
    my ( $params ) = @_;
120
    my ( $params ) = @_;
121
121
122
    C4::Context->_new_userenv(42);
123
124
    my $userenv;
122
    my $userenv;
125
    if ( $params and my $patron = $params->{patron} ) {
123
    if ( $params and my $patron = $params->{patron} ) {
126
        $userenv = $patron->unblessed;
124
        $userenv = $patron->unblessed;
127
- 

Return to bug 36367