Bug 28383

Summary: Log in via the itemsearch URL leads to Internal Server Error
Product: Koha Reporter: Christian Stelzenm├╝ller <christian.stelzenmueller>
Component: CatalogingAssignee: Jonathan Druart <jonathan.druart+koha>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, dcook, fridolin.somers, jonathan.druart+koha, julian.maurice, kyle, m.de.rooy, victor
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Text to go in the release notes:
When trying to access the item search form in the staff interface (/cgi-bin/koha/catalogue/itemsearch.pl) when not logged in, an internal server error (error code 500) is received after entering your login details. This fixes the problem so that the item search form is displayed as expected.
Version(s) released in:
21.11.00,21.05.01,20.11.07
Attachments: Bug 28383: Fix itemsearch when accessed from the login form
Bug 28383: Fix itemsearch when accessed from the login form
Bug 28383: Fix itemsearch when accessed from the login form

Description Christian Stelzenm├╝ller 2021-05-19 08:35:43 UTC
- Try to access the itemsearch-URL for the staff without beeing logged in
... cgi-bin/koha/catalogue/itemsearch.pl

- Log in 

- Internal Server Error
Comment 1 Fridolin Somers 2021-06-11 10:24:50 UTC
Oh crap indeed.

I think it comes from :

my $cgi = CGI->new;
my %params = $cgi->Vars;
 ...
if (scalar keys %params > 0) {
    # Parameters given, it's a search

In case of authentication, user and password are params.

Maybe we can test if $format param is defined.
Comment 2 Jonathan Druart 2021-06-11 11:27:50 UTC
Created attachment 121819 [details] [review]
Bug 28383: Fix itemsearch when accessed from the login form

There are params here (credentials), we need to test for the existence of $format.

Test plan:
logout
access /cgi-bin/koha/catalogue/itemsearch.pl
Login
=> Without this patch you get a 500 (because we hit the exit statement)
=> With this patch you see the items search form.
Comment 3 David Nind 2021-06-12 22:34:56 UTC
Created attachment 121893 [details] [review]
Bug 28383: Fix itemsearch when accessed from the login form

There are params here (credentials), we need to test for the existence of $format.

Test plan:
logout
access /cgi-bin/koha/catalogue/itemsearch.pl
Login
=> Without this patch you get a 500 (because we hit the exit statement)
=> With this patch you see the items search form.

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 Katrin Fischer 2021-06-14 19:33:26 UTC
Created attachment 121932 [details] [review]
Bug 28383: Fix itemsearch when accessed from the login form

There are params here (credentials), we need to test for the existence of $format.

Test plan:
logout
access /cgi-bin/koha/catalogue/itemsearch.pl
Login
=> Without this patch you get a 500 (because we hit the exit statement)
=> With this patch you see the items search form.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 David Cook 2021-06-14 23:51:23 UTC
(As a side note, this makes me think about how it would be good if we had 1 login point like "/cgi-bin/koha/login" which then redirected you back to your entrypoint after successful login)
Comment 6 Jonathan Druart 2021-06-15 14:28:46 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 7 Kyle M Hall 2021-06-18 14:51:42 UTC
Pushed to 21.05.x for 21.05.01
Comment 8 Fridolin Somers 2021-06-21 13:27:37 UTC
Pushed to 20.11.x for 20.11.07
Comment 9 Victor Grousset/tuxayo 2021-06-22 01:07:58 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.