Bug 39072 - Item search shareable link adding selections for similar LOC auth values
Summary: Item search shareable link adding selections for similar LOC auth values
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Testopia
URL:
Keywords:
Depends on: 14322
Blocks:
  Show dependency treegraph
 
Reported: 2025-02-09 22:24 UTC by Heather Rommens
Modified: 2025-08-20 17:14 UTC (History)
8 users (show)

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


Attachments
Bug 39072: Only select exact matches when populating search terms (2.30 KB, patch)
2025-08-14 13:17 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 39072: Only select exact matches when populating search terms (2.35 KB, patch)
2025-08-20 16:44 UTC, Brendan Lawlor
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Heather Rommens 2025-02-09 22:24:51 UTC
When executing an Item Search and copying the shareable link, the Item Search results for the shared link differ from the original results. Specifically, if a LOC authorized value is similar to another authorized value (ex: ADULT with description Adult and ADULTG with description Adult - Grab and Go), if an Item Search is executed for the ADULTG LOC, the shareable link somehow includes the ADULT LOC, causing the results to differ radically from the initial search.

To Test:
- Create LOC authorized values of ADULT with description "Adult" and ADULTG with description "Adult - Grab and Go"
- Create an Item Search using the ADULTG LOC value
- Click Copy shareable link and paste/go in new tab
- See that the results of the copied link's Item Search differ widely from the original results
- Click Edit search button and notice that the LOC authorized value of ADULT was added to the selected criteria for the search
Comment 1 Heather Rommens 2025-02-09 22:29:28 UTC
Adding a comment to mention that this issue appears to be very similar to the bug reported in Comment 18 on Bug 14322 - Add option to create a shareable link for item searches.
Comment 2 Sarah Cornell 2025-04-17 15:01:01 UTC
We're having the same problem with this feature.  

The link to a search for for PYBWF will return items with PYBWF and those with location PY.

The link to a search for PYMG will return items with location codes PYMG, PYM, and PY.

All of our location codes are built on this structure so the link feature won't be useful to us until the search is exact.
Comment 3 Nick Clemens (kidclamp) 2025-08-14 13:17:49 UTC
Created attachment 185393 [details] [review]
Bug 39072: Only select exact matches when populating search terms

This patch simply reduces our matching pattern to ensure the string is an exact match, rather than partial

To test:
- Create LOC authorized values of ADULT with description "Adult" and ADULTG with description "Adult - Grab and Go"
- Find a record with items and set one item to shelving location "Adult"
- Find a second record with items and set one item to shelving location "Adult - Grab and Go"
- Create an Item Search for Shelving location and select 'Adult' only
- Search and get one result from the record selected above
- Click Copy shareable link and paste/go in new tab
- See that the results now include both records from above
- Click Edit search button and notice that the Shelving location 'Adult - Grab and Go'  was added to the selected criteria for the search
- Apply patch
- Repeat original search for 'Adult' location
- Click 'Copy shareable link'
- Open in new tab and confirm correct results
- Repeat with a search for 'Adult - Grab and Go' and confirm shareable link gets the correct results
Comment 4 Anneli Österman 2025-08-15 11:53:52 UTC
I tested this in a several sandboxes but I could not replicate the original problem. The shared link worked correctly.
Comment 5 Brendan Lawlor 2025-08-20 16:44:57 UTC
Created attachment 185599 [details] [review]
Bug 39072: Only select exact matches when populating search terms

This patch simply reduces our matching pattern to ensure the string is an exact match, rather than partial

To test:
- Create LOC authorized values of ADULT with description "Adult" and ADULTG with description "Adult - Grab and Go"
- Find a record with items and set one item to shelving location "Adult"
- Find a second record with items and set one item to shelving location "Adult - Grab and Go"
- Create an Item Search for Shelving location and select 'Adult' only
- Search and get one result from the record selected above
- Click Copy shareable link and paste/go in new tab
- See that the results now include both records from above
- Click Edit search button and notice that the Shelving location 'Adult - Grab and Go'  was added to the selected criteria for the search
- Apply patch
- Repeat original search for 'Adult' location
- Click 'Copy shareable link'
- Open in new tab and confirm correct results
- Repeat with a search for 'Adult - Grab and Go' and confirm shareable link gets the correct results

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 6 Brendan Lawlor 2025-08-20 17:06:19 UTC
This works and makes sense that the grep function should have a regular expression with an exact matching start and end.

When testing I found that the test plan was slightly off, so it could be confusing to replicate.

Copying the link for the Adult grab and go link and pasting it actually returns the results for selecting both Adult and Adult grab and go.

To test:
Create LOC authorized values of ADULT with description "Adult" and ADULTG with description "Adult - Grab and Go"
- Find a record with items and set one item to shelving location "Adult"
- Find a second record with items and set one item to shelving location "Adult - Grab and Go"


*This step should be for Adult grab and go:
- Create an Item Search for Shelving location and select 'Adult grab and go' only
- Search and get one result from the record selected above
- Click Copy shareable link and paste/go in new tab
- See that the results now include both records from above

*This step you should see the Adult shelving location was added when it shouldn't be:
- Click Edit search button and notice that the Shelving location 'Adult'  was added to the selected criteria for the search
Comment 7 Brendan Lawlor 2025-08-20 17:14:11 UTC
It's counterintuitive that the param that's longer actually selects the option that's shorter, but what's happening is it takes the url query param value for location, ADULTG and greps for the values of the options, so both option values ADULT and ADULTG match.

That's why it's selecting both options when you paste the link for the longer param ADULTG.

I would be happy to switch my sign off to QA if someone else signs off.