Bugzilla – Attachment 178081 Details for
Bug 36025
Extended attributes clause added to patron search query even when there are no searchable attributes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36025: Incorrect clause in patron search
Bug-36025-Incorrect-clause-in-patron-search.patch (text/plain), 4.20 KB, created by
Marcel de Rooy
on 2025-02-14 08:33:46 UTC
(
hide
)
Description:
Bug 36025: Incorrect clause in patron search
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2025-02-14 08:33:46 UTC
Size:
4.20 KB
patch
obsolete
>From 27973ec8c7d68b53629328318a8376bc5a2f0363 Mon Sep 17 00:00:00 2001 >From: Andreas Jonsson <andreas.jonsson@kreablo.se> >Date: Thu, 8 Feb 2024 01:08:10 +0000 >Subject: [PATCH] Bug 36025: Incorrect clause in patron search >Content-Type: text/plain; charset=utf-8 > >This patch removes the search clause for >extended_attributes when there is no patron >attribute types which are searchable by default. > >The clause was incorrectly added because the array >extended_attribute_types was rendered as [""] > >This seems to be an issue with get_columns from DBIX Class and how that is cast when forcing an array >in the template. It returns an empty string for nothing, a scalar for a single value, and an array for multiple >values. > >This patch now checks if the variable is set and has content, and wraps as an array if so. In the case of two attributes, >we do double the array, but this was true before as we always cast the return as an array. > >Test plan: > >* Make sure that no borrower attribute type is set to "searched by default" > in Koha administration -> Patron attribute types. >* Enable the network monitring in the developer tools in your web browser > (Ctrl + Shift + E in firefox or Ctrl + Shift + I and select the "Network" > tab). >* Go to the patrons view members-home.pl (click patrons in top menu bar). >* Search for a string that will match multiple borrowers (to not be automatically > redirected) >* Examine the ajax-request and make sure that "extended_attributes.code" is NOT > part of the query. >* Also, in koha-testing-docker with selenium enabled, > run 'perl t/db_dependent/selenium/patrons_search.t' >* Now set one patro attribute to searchable and searched by default and add a value for a patron, confirm search works >* Set a second patron attribute to searchable and searched by default and confirm searching works > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Magnus Enger <magnus@libriotech.no> >Works as advertised. Did not run the selenium tests, as they have >been obsoleted. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Template/Plugin/ExtendedAttributeTypes.pm | 2 ++ > koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc | 3 ++- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 2 +- > 3 files changed, 5 insertions(+), 2 deletions(-) > >diff --git a/Koha/Template/Plugin/ExtendedAttributeTypes.pm b/Koha/Template/Plugin/ExtendedAttributeTypes.pm >index 9511b7325e..837e014fa8 100644 >--- a/Koha/Template/Plugin/ExtendedAttributeTypes.pm >+++ b/Koha/Template/Plugin/ExtendedAttributeTypes.pm >@@ -33,7 +33,9 @@ sub all { > > sub codes { > my ( $self, $params ) = @_; >+ > return Koha::Patron::Attribute::Types->search($params)->get_column('code'); >+ > } > > 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index ba17bf990f..46dee3a0cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -286,7 +286,8 @@ > }, {}); > > [% IF Koha.Preference('ExtendedPatronAttributes') %] >- [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %] >+ [% SET extended_attribute_types = ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) %] >+ [% IF ( extended_attribute_types ) %][% extended_attribute_types = [ extended_attribute_types ] %][% END %] > var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 522689055f..b219551f6f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -909,7 +909,7 @@ function buildPatronSearchQuery(term, options) { > if ( > typeof options !== "undefined" && > ((options.search_fields == "standard" && >- options.extended_attribute_types) || >+ options.extended_attribute_types.length > 0) || > searched_attribute_fields.length > 0) && > extendedPatronAttributes > ) { >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36025
:
161873
|
161874
|
161914
|
161915
|
175917
|
175918
|
175952
|
176747
|
176748
|
176823
|
176824
|
178037
|
178038
|
178039
| 178081 |
178082
|
178083