Bug 26445

Summary: Search results browser in staff has broken link back to results
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: Staff ClientAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Martin Renvoize <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: aleisha, dcook, eb, gmcharlt, jonathan.druart, lucas, martin.renvoize
Version: masterKeywords: Academy
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Who signed the patch off: Manual merge request:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.06
Attachments: Bug 26445: Fix "back to result" link of the search result browser
Bug 26445: Fix "back to result" link of the search result browser
Bug 26445: Fix "back to result" link of the search result browser

Description Katrin Fischer 2020-09-12 17:40:19 UTC
To test:
- Do a search in the staff client returning 2-3 results
- Open the first result
- Click on the "back to results" link on the left
- Verify that the link is wrong/not working

In my case I searched for "test" in the sample data, it returned 3 records. The search link back to results looks like this:

http://localhost:8081/cgi-bin/koha/catalogue/search.pl?idx=kw&q=test&sort_by=relevance_dsc&searchid=scs_1599932246462&offset=9

The offset=9 is the issue and clearly wrong.
Comment 1 Elaine Bradtke 2020-09-14 21:27:46 UTC
We've seen this too, it happens only in the staff interface.  It works for some records, and not others, consistently.  
With a list of search results, clicking on a title takes us to the bib record as expected, but when we click results to go back to the list, we get a blank results page. No error message, but no titles listed.
If we sort the results list, the titles appear.
As I said above, it only happens to certain records, which led me to suspect there's a problem in the MARC somewhere.  Experimenting with one of them, I've tried the following:
1) Checked the record in MarcEdit - it didn't flag up any problems.
2) Replaced the offending record with a Z39.50 download from LC
3) Deleted the record and re-catalogued it using a template that we have.
4) Catalogued it completely from scratch - without a template  (the template has the same problem!).

No change.  We still get the blank results page.
Comment 2 Katrin Fischer 2020-09-14 21:47:54 UTC
I think it might be related to short result lists and a wrong calculation of the offset parameter. The offset defines where in the list we return to (the page... the result number), but for my result list of 3 it shows 9 - which makes a jump behind the existing results - blank page.
Comment 3 Elaine Bradtke 2020-09-15 16:21:24 UTC
I don't think the list length makes a difference.  From the last record in a list of 1987 records, we get offset=195101

Other interesting behaviours from this long list.  It seems like records in the first few pages of results work, but when you go back to results, it advances to the next page of results.  If the record is on the first page of results, going back to results lands you on the second page of results and so on. Records towards the end of the list give a blank page.  It's almost as if  something is increasing the number of records the system is trying to retrieve. In a long list, some will work, but eventually it starts looking for more records than are in the results.  There be dragons!
Comment 4 Jonathan Druart 2020-10-15 08:52:55 UTC
Created attachment 111684 [details] [review]
Bug 26445: Fix "back to result" link of the search result browser

Not sure what was the expected behaviour, I am suggesting the following
one:
If you are browsing and you click "back to result", you will be
redirected to the page where the record appear on the search result
list.

Say you search for "something" that returns 10 page (20 results per
page)
Click on first result first page
Click back to result
=> You see the first page with the first result at the top

Click on second page, 3rd result
Click back to result
=> You see the second page with the biblio you clicked at the 3rd
position

Click on second page, 3rd result
Click next/previous
Click back to result
=> You see the page where you last result were.

I think the existing expected behaviour was to have the result you
clicked at the first position of the result page, but I am not sure it
really makes sense.

Hope this makes sense however!
Comment 5 Jonathan Druart 2020-10-15 08:53:21 UTC
Has this been always been broken or it's a regression?
Comment 6 Katrin Fischer 2020-10-15 09:27:47 UTC
I believe it is a regression as I have used the link in past versions, but it might have been broken for quite a long while.
Comment 7 Owen Leonard 2020-10-16 11:23:07 UTC
Created attachment 111861 [details] [review]
Bug 26445: Fix "back to result" link of the search result browser

Not sure what was the expected behaviour, I am suggesting the following
one:
If you are browsing and you click "back to result", you will be
redirected to the page where the record appear on the search result
list.

Say you search for "something" that returns 10 page (20 results per
page)
Click on first result first page
Click back to result
=> You see the first page with the first result at the top

Click on second page, 3rd result
Click back to result
=> You see the second page with the biblio you clicked at the 3rd
position

Click on second page, 3rd result
Click next/previous
Click back to result
=> You see the page where you last result were.

I think the existing expected behaviour was to have the result you
clicked at the first position of the result page, but I am not sure it
really makes sense.

Hope this makes sense however!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 8 Martin Renvoize 2020-10-16 13:58:04 UTC
Created attachment 111877 [details] [review]
Bug 26445: Fix "back to result" link of the search result browser

Not sure what was the expected behaviour, I am suggesting the following
one:
If you are browsing and you click "back to result", you will be
redirected to the page where the record appear on the search result
list.

Say you search for "something" that returns 10 page (20 results per
page)
Click on first result first page
Click back to result
=> You see the first page with the first result at the top

Click on second page, 3rd result
Click back to result
=> You see the second page with the biblio you clicked at the 3rd
position

Click on second page, 3rd result
Click next/previous
Click back to result
=> You see the page where you last result were.

I think the existing expected behaviour was to have the result you
clicked at the first position of the result page, but I am not sure it
really makes sense.

Hope this makes sense however!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize 2020-10-16 13:58:29 UTC
Works as expected and code makes sense.. Passing QA
Comment 10 Jonathan Druart 2020-10-25 23:06:38 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 11 Lucas Gass 2020-11-13 19:01:14 UTC
backported to 20.05.x for 20.05.06
Comment 12 Aleisha Amohia 2020-11-17 04:38:08 UTC
i can't reproduce this in 19.11.x. not backported