Bug 27697 - Opening bibliographic record page prepopulates search bar text
Summary: Opening bibliographic record page prepopulates search bar text
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: PC Windows
: P5 - low minor
Assignee: Nick Clemens (kidclamp)
QA Contact: Testopia
URL:
Keywords:
Depends on: 23475
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-12 17:47 UTC by Elaina Komala
Modified: 2023-12-28 20:42 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.01, 21.11.07
Circulation function:


Attachments
Bug 27697: Only preopulate search when we have found a single biblio (2.90 KB, patch)
2022-05-18 15:13 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 27697: Only preopulate search when we have found a single biblio (2.95 KB, patch)
2022-05-31 02:56 UTC, David Nind
Details | Diff | Splinter Review
Bug 27697: Only preopulate search when we have found a single biblio (3.03 KB, patch)
2022-05-31 07:02 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Elaina Komala 2021-02-12 17:47:32 UTC
On the staff client end: Opening a bibliographic record page populates the search bar with the last text entered in the Search the Catalog search bar for that browser session, even if the search wasn't done on the previous page or tab or by the same logged in user. This also happens when links are opened in new tabs. It only prepopulates search text from the Search the Catalog search bar, not from Advanced Search.

Only able to recreate the bug on pages that load within the Normal tab of a bibliographic record page: 
https://staff.**.bywatersolutions.com/cgi-bin/koha/catalogue/detail.pl?biblionumber=** 
(including #description, #acq_details, #images)

1. Enter text in the Search the Catalog search bar and Submit
2. Click on a search result to open the record page
3. Search field is prepopulated with previous search text
Even as you click through to other pages, on and on, once you open another record page, the search bar will once again prepopulate the last text entered in it.

Example that automatically opens in new tab, not directly from a search result:

1. Enter text in the Search the Catalog search bar and Submit
2. Open Tools › Manage staged MARC records › Batch #
3. Click on Record # in righthand column
4. Record page opens in new tab with previous search text prepopulated

The search bar should clear out upon loading a new page or tab. One user's search history should never load for another user, despite not closing out and reopening the browser.
Comment 1 Jonathan Druart 2021-02-15 14:54:13 UTC
It has been added by bug 23475.

Nick, maybe we should use sessionStorage instead of localStorage?
Comment 2 Jonathan Druart 2022-05-18 09:26:09 UTC
Nick, this is very confusing IMO. We should invalidate/reset the value at some point. It's not consistent to have the input prefilled if we are coming from another view than the result view.
Comment 3 Jonathan Druart 2022-05-18 09:32:09 UTC
Ha, it's bug 26247.

*** This bug has been marked as a duplicate of bug 26247 ***
Comment 4 Nick Clemens (kidclamp) 2022-05-18 15:13:38 UTC
Created attachment 135146 [details] [review]
Bug 27697: Only preopulate search when we have found a single biblio

This patch uses the url parameter we created in 23475 to determine whether
we should populate the search bar or not

Note - a bookmark with this param will still populate search term with last search

To test:
1 - Search staff client for 'cat'
2 - Browse to a patrons checkouts and click on a title, or just go directly to a details page:
    http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850
3 - Search bar says 'cat'
4 - Apply patch
5 - Repeat 1-2
6 - Search bar is not populated
7 - Search "dalek war box set" or a term that finds a single record in your instance
8 - Search bar is populated
9 - Note url like: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850&found1=1
Comment 5 Nick Clemens (kidclamp) 2022-05-18 15:15:12 UTC
(In reply to Jonathan Druart from comment #3)
> Ha, it's bug 26247.
> 
> *** This bug has been marked as a duplicate of bug 26247 ***

I unduplicated - that seems more about copying between boxes - this is about populating when we shouldn't
Comment 6 David Nind 2022-05-31 02:56:32 UTC
Created attachment 135457 [details] [review]
Bug 27697: Only preopulate search when we have found a single biblio

This patch uses the url parameter we created in 23475 to determine whether
we should populate the search bar or not

Note - a bookmark with this param will still populate search term with last search

To test:
1 - Search staff client for 'cat'
2 - Browse to a patrons checkouts and click on a title, or just go directly to a details page:
    http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850
3 - Search bar says 'cat'
4 - Apply patch
5 - Repeat 1-2
6 - Search bar is not populated
7 - Search "dalek war box set" or a term that finds a single record in your instance
8 - Search bar is populated
9 - Note url like: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850&found1=1

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Jonathan Druart 2022-05-31 07:02:35 UTC
Created attachment 135468 [details] [review]
Bug 27697: Only preopulate search when we have found a single biblio

This patch uses the url parameter we created in 23475 to determine whether
we should populate the search bar or not

Note - a bookmark with this param will still populate search term with last search

To test:
1 - Search staff client for 'cat'
2 - Browse to a patrons checkouts and click on a title, or just go directly to a details page:
    http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850
3 - Search bar says 'cat'
4 - Apply patch
5 - Repeat 1-2
6 - Search bar is not populated
7 - Search "dalek war box set" or a term that finds a single record in your instance
8 - Search bar is populated
9 - Note url like: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850&found1=1

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Tomás Cohen Arazi (tcohen) 2022-06-02 16:44:14 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 9 Lucas Gass (lukeg) 2022-06-10 16:46:15 UTC
Pushed to 22.05.x for 22.05.01
Comment 10 Jonathan Druart 2022-06-16 10:43:04 UTC
This adds a new warning in the log

[2022/06/16 10:31:18] [WARN] CGI::param called in list context from /kohadevbox/koha/catalogue/detail.pl line 626, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/share/perl5/CGI.pm line 414.

It should be 

  $template->param(found1 => scalar $query->param('found1') );
Comment 11 Jonathan Druart 2022-06-21 07:13:42 UTC
(In reply to Jonathan Druart from comment #10)
> This adds a new warning in the log
> 
> [2022/06/16 10:31:18] [WARN] CGI::param called in list context from
> /kohadevbox/koha/catalogue/detail.pl line 626, this can lead to
> vulnerabilities. See the warning in "Fetching the value or values of a
> single named parameter" at /usr/share/perl5/CGI.pm line 414.
> 
> It should be 
> 
>   $template->param(found1 => scalar $query->param('found1') );

See bug 30997.
Comment 12 Arthur Suzuki 2022-06-21 13:35:48 UTC
thx pushed to 21.11.x for 21.11.07
Comment 13 Victor Grousset/tuxayo 2022-06-25 23:57:52 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.
Comment 14 Caroline Cyr La Rose 2023-05-09 16:27:16 UTC
This seems like a bug fix rather than a feature. Not sure what documentation is needed. Closing, but feel free to reopen with details.