Bug 31244

Summary: Logout when not logged in raise a 500
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Victor Grousset/tuxayo <victor>
Severity: normal    
Priority: P5 - low CC: arthur.suzuki, gmcharlt, lucas, martin.renvoize, sally.healey, victor, wainuiwitikapark
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.05, 21.11.16
Circulation function:
Bug Depends on:    
Bug Blocks: 30588    
Attachments: Bug 31244: Fix 500 if logout and not logged in
Bug 31244: Fix 500 if logout and not logged in
Bug 31244: Fix 500 if logout and not logged in
Bug 31244: [21.11.x] Fix 500 if logout and not logged in
Bug 31244: [21.11.x] Fix 500 if logout and not logged in

Description Jonathan Druart 2022-07-27 07:07:00 UTC
If /cgi-bin/koha/mainpage.pl?logout.x=1 is hit when the user is not logged in, a 500 is displayed.

    Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
            C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
            C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40
Comment 1 Jonathan Druart 2022-07-27 07:07:57 UTC
Created attachment 138147 [details] [review]
Bug 31244: Fix 500 if logout and not logged in

Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
        C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
        C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40

Test plan:
Open a private window
Hit /cgi-bin/koha/mainpage.pl?logout.x=1
Comment 2 ByWater Sandboxes 2022-07-27 07:24:02 UTC
Created attachment 138148 [details] [review]
Bug 31244: Fix 500 if logout and not logged in

Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
        C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
        C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40

Test plan:
Open a private window
Hit /cgi-bin/koha/mainpage.pl?logout.x=1

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Sally 2022-07-27 07:24:41 UTC
Works as described - signing off.  Thanks for the patch!
Comment 4 Victor Grousset/tuxayo 2022-07-27 22:54:59 UTC
Created attachment 138188 [details] [review]
Bug 31244: Fix 500 if logout and not logged in

Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
        C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
        C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40

Test plan:
Open a private window
Hit /cgi-bin/koha/mainpage.pl?logout.x=1

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 5 Victor Grousset/tuxayo 2022-07-27 22:55:19 UTC
Works, qa script happy, code looks good, passing QA :)
Comment 6 Tomás Cohen Arazi (tcohen) 2022-07-28 13:15:17 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 7 Lucas Gass (lukeg) 2022-09-02 20:29:40 UTC
Backported to 22.05.x for 22.05.05
Comment 8 Arthur Suzuki 2022-09-14 11:49:13 UTC
Won't backport to 21.11.x.
Issue not reproduced + the patch breaks perl compilation.
'''
Starting Z39.50/SRU daemon for kohadev:Global symbol "$auth_state" requires explicit package name (did you forget to declare "my $auth_state"?) at /kohadevbox/koha/C4/Auth.pm line 982.
BEGIN not safe after errors--compilation aborted at /kohadevbox/koha/C4/Auth.pm line 2001.
'''
Comment 9 Martin Renvoize (ashimema) 2023-01-26 17:35:58 UTC
This also affects 21.11.x

I'm not sure how you were getting the error you suggest you have Arthur.. we don't introduce auth_state here at all.
Comment 10 Martin Renvoize (ashimema) 2023-01-26 17:36:59 UTC
It's easy to replicate in the shibboleth environment.. it's very hard without.
Comment 11 Martin Renvoize (ashimema) 2023-01-26 17:42:50 UTC
OK.. I see.. the conflict comes out really wierd..

I'll drop a 21.11.x specific patch here in a few minutes.
Comment 12 Martin Renvoize (ashimema) 2023-01-26 17:45:17 UTC
Created attachment 145696 [details] [review]
Bug 31244: [21.11.x] Fix 500 if logout and not logged in

Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
        C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
        C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40

Test plan:
Open a private window
Hit /cgi-bin/koha/mainpage.pl?logout.x=1

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Rebased for 21.11.x
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize (ashimema) 2023-01-27 08:35:08 UTC
Created attachment 145717 [details] [review]
Bug 31244: [21.11.x] Fix 500 if logout and not logged in

Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985
        C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186
        C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40

Test plan:
Open a private window
Hit /cgi-bin/koha/mainpage.pl?logout.x=1

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Rebased for 21.11.x
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Arthur Suzuki 2023-01-27 10:12:36 UTC
applied to 21.11.x for 21.11.16
Comment 15 Wainui Witika-Park 2023-03-15 01:37:41 UTC
Not backported to 21.05.x