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 1306-1312 sub checkauth { Link Here
1306
            else {
1305
            else {
1307
                if ($userid) {
1306
                if ($userid) {
1308
                    $info{'invalid_username_or_password'} = 1;
1307
                    $info{'invalid_username_or_password'} = 1;
1309
                    C4::Context::_unset_userenv($sessionID);
1308
                    C4::Context::unset_userenv();
1310
                }
1309
                }
1311
                $session->param( 'lasttime', time() );
1310
                $session->param( 'lasttime', time() );
1312
                $session->param( 'ip',       $session->remote_addr() );
1311
                $session->param( 'ip',       $session->remote_addr() );
Lines 1667-1673 sub check_api_auth { Link Here
1667
            return ( "failed", undef, undef ) unless $session;
1666
            return ( "failed", undef, undef ) unless $session;
1668
1667
1669
            my $sessionID = $session->id;
1668
            my $sessionID = $session->id;
1670
            C4::Context->_new_userenv($sessionID);
1671
            my $cookie = $query->cookie(
1669
            my $cookie = $query->cookie(
1672
                -name     => 'CGISESSID',
1670
                -name     => 'CGISESSID',
1673
                -value    => $sessionID,
1671
                -value    => $sessionID,
Lines 1831-1837 sub check_cookie_auth { Link Here
1831
    unless ( $sessionID ) {
1829
    unless ( $sessionID ) {
1832
        return ( "failed", undef );
1830
        return ( "failed", undef );
1833
    }
1831
    }
1834
    C4::Context::_unset_userenv($sessionID); # remove old userenv first
1832
    C4::Context::unset_userenv();
1835
    my $session   = get_session($sessionID);
1833
    my $session   = get_session($sessionID);
1836
    if ($session) {
1834
    if ($session) {
1837
        my $userid   = $session->param('id');
1835
        my $userid   = $session->param('id');
Lines 1868-1874 sub check_cookie_auth { Link Here
1868
            return ("password_expired", undef ) if $patron->password_expired;
1866
            return ("password_expired", undef ) if $patron->password_expired;
1869
            my $flags = defined($flagsrequired) ? haspermission( $userid, $flagsrequired ) : 1;
1867
            my $flags = defined($flagsrequired) ? haspermission( $userid, $flagsrequired ) : 1;
1870
            if ($flags) {
1868
            if ($flags) {
1871
                C4::Context->_new_userenv($sessionID);
1872
                if ( !C4::Context->interface ) {
1869
                if ( !C4::Context->interface ) {
1873
                    # No need to override the interface, most often set by get_template_and_user
1870
                    # No need to override the interface, most often set by get_template_and_user
1874
                    C4::Context->interface( $session->param('interface') );
1871
                    C4::Context->interface( $session->param('interface') );
Lines 1898-1904 sub check_cookie_auth { Link Here
1898
            }
1895
            }
1899
1896
1900
        } else {
1897
        } else {
1901
            C4::Context->_new_userenv($sessionID);
1902
            C4::Context->interface($session->param('interface'));
1898
            C4::Context->interface($session->param('interface'));
1903
            C4::Context->set_userenv( undef, q{} );
1899
            C4::Context->set_userenv( undef, q{} );
1904
            return ( "anon", $session );
1900
            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 758-776 sub restore_dbh Link Here
758
757
759
Retrieves a hash for user environment variables.
758
Retrieves a hash for user environment variables.
760
759
761
This hash shall be cached for future use: if you call
762
C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
763
764
=cut
760
=cut
765
761
766
#'
767
sub userenv {
762
sub userenv {
768
    my $var = $context->{"activeuser"};
763
    return $context->{userenv};
769
    if (defined $var and defined $context->{"userenv"}->{$var}) {
770
        return $context->{"userenv"}->{$var};
771
    } else {
772
        return;
773
    }
774
}
764
}
775
765
776
=head2 set_userenv
766
=head2 set_userenv
Lines 798-804 sub set_userenv { Link Here
798
        $register_id,  $register_name
788
        $register_id,  $register_name
799
    ) = @_;
789
    ) = @_;
800
790
801
    my $var=$context->{"activeuser"} || '';
802
    my $cell = {
791
    my $cell = {
803
        "number"     => $usernum,
792
        "number"     => $usernum,
804
        "id"         => $userid,
793
        "id"         => $userid,
Lines 817-860 sub set_userenv { Link Here
817
        "register_id"   => $register_id,
806
        "register_id"   => $register_id,
818
        "register_name" => $register_name
807
        "register_name" => $register_name
819
    };
808
    };
820
    $context->{userenv}->{$var} = $cell;
809
    $context->{userenv} = $cell;
821
    return $cell;
810
    return $cell;
822
}
811
}
823
812
824
=head2 _new_userenv
813
=head2 unset_userenv
825
826
  C4::Context->_new_userenv($session);  # FIXME: This calling style is wrong for what looks like an _internal function
827
828
Builds a hash for user environment variables.
829
830
This hash shall be cached for future use: if you call
831
C<C4::Context-E<gt>userenv> twice, you will get the same hash without real DB access
832
833
_new_userenv is called in Auth.pm
834
835
=cut
836
837
#'
838
sub _new_userenv
839
{
840
    shift;  # Useless except it compensates for bad calling style
841
    my ($sessionID)= @_;
842
     $context->{"activeuser"}=$sessionID;
843
}
844
845
=head2 _unset_userenv
846
814
847
  C4::Context->_unset_userenv;
815
  C4::Context->unset_userenv;
848
816
849
Destroys the hash for activeuser user environment variables.
817
Destroys user environment variables.
850
818
851
=cut
819
=cut
852
820
853
#'
821
sub unset_userenv
854
855
sub _unset_userenv
856
{
822
{
857
    delete $context->{activeuser};
823
    $context->{userenv} = {};
858
}
824
}
859
825
860
826
(-)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 568-574 sub _set_userenv { Link Here
568
        $THE_library = $patron->library;
568
        $THE_library = $patron->library;
569
    }
569
    }
570
570
571
    C4::Context->_new_userenv( $patron->borrowernumber );
571
    C4::Context->new_userenv();
572
    C4::Context->set_userenv(
572
    C4::Context->set_userenv(
573
        $patron->borrowernumber,  # number,
573
        $patron->borrowernumber,  # number,
574
        $patron->userid,          # userid,
574
        $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