Bug 34760

Summary: Prevent error when logging into OPAC after conducting a search
Product: Koha Reporter: Aleisha Amohia <aleisha>
Component: OPACAssignee: Aleisha Amohia <aleisha>
Status: Pushed to oldstable --- QA Contact: Katrin Fischer <katrin.fischer>
Severity: normal    
Priority: P5 - low CC: fridolin.somers
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.04,22.11.11
Attachments: Bug 34760: Confirm session ID is set to save OPAC search history to logged in user
Bug 34760: Confirm session ID is set to save OPAC search history to logged in user
Bug 34760: Confirm session ID is set to save OPAC search history to logged in user

Description Aleisha Amohia 2023-09-11 20:46:16 UTC
If you have EnableOpacSearchHistory system preference enabled, Koha will either save search history to the session, or if logged in then Koha will save search history to the patron.

If you do a search on the OPAC, then try to log in with SSO, an error could be thrown if the session ID wasn't saved to the cookie correctly. We should prevent this by checking if a session ID was set before trying to save search history to a logged in patron.
Comment 1 Aleisha Amohia 2023-09-11 21:04:00 UTC
Created attachment 155521 [details] [review]
Bug 34760: Confirm session ID is set to save OPAC search history to logged in user

This patch confirms that a session ID has been set before trying to save search history to a logged in user on the OPAC.

This depends on EnableOpacSearchHistory system preference being enabled.

Apply the patch and test that you don't see an Error 500 page at any point through this plan:

1. Do an OPAC search, ensure you are not logged in
2. Confirm your search was saved to search history
3. Do another search, then log in
4. Confirm you are brought back to the search results after logging in
5. Confirm all search history from the session is visible

Sponsored-by: Toi Ohomai Institute of Technology
Comment 2 Salah Ghedda 2023-09-12 14:09:43 UTC
Created attachment 155550 [details] [review]
Bug 34760: Confirm session ID is set to save OPAC search history to logged in user

This patch confirms that a session ID has been set before trying to save search history to a logged in user on the OPAC.

This depends on EnableOpacSearchHistory system preference being enabled.

Apply the patch and test that you don't see an Error 500 page at any point through this plan:

1. Do an OPAC search, ensure you are not logged in
2. Confirm your search was saved to search history
3. Do another search, then log in
4. Confirm you are brought back to the search results after logging in
5. Confirm all search history from the session is visible

Sponsored-by: Toi Ohomai Institute of Technology
Signed-off-by: Salah Ghedda <salah.ghedda@inLibro.com>
Comment 3 Katrin Fischer 2023-09-17 14:49:43 UTC
I have mostly done regression testing here as I can't test any of the SSO methods. I also verified it that the behaviour with  LoadSearchHistoryToTheFirstLoggedUser is still the same.
Comment 4 Katrin Fischer 2023-09-17 14:50:16 UTC
Created attachment 155762 [details] [review]
Bug 34760: Confirm session ID is set to save OPAC search history to logged in user

This patch confirms that a session ID has been set before trying to save search history to a logged in user on the OPAC.

This depends on EnableOpacSearchHistory system preference being enabled.

Apply the patch and test that you don't see an Error 500 page at any point through this plan:

1. Do an OPAC search, ensure you are not logged in
2. Confirm your search was saved to search history
3. Do another search, then log in
4. Confirm you are brought back to the search results after logging in
5. Confirm all search history from the session is visible

Sponsored-by: Toi Ohomai Institute of Technology
Signed-off-by: Salah Ghedda <salah.ghedda@inLibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi 2023-09-19 19:35:52 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 6 Fridolin Somers 2023-09-21 06:22:03 UTC
Pushed to 23.05.x for 23.05.04
Comment 7 Matt Blenkinsop 2023-10-12 16:11:15 UTC
Nice work everyone!

Pushed to oldstable for 22.11.x