Description
Andreas Jonsson
2024-02-07 20:16:26 UTC
There is also another issue in buildPatronSearchQuery that still adds the clause. Someone is trying to use an array as a boolean value in Javascript. (A work related brain injury caused by excessive Perl programming?) --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -650,7 +650,7 @@ function buildPatronSearchQuery(term, options) { q.push({ "-or": term_subquery_or }); // Add each pattern for each extended patron attributes - if ( typeof options !== 'undefined' && ( (options.search_fields == 'standard' && options.extended_attribute_types) || ( searched_attribute_fields.length > 0 ) ) && extendedPatronAttributes) { + if ( typeof options !== 'undefined' && ( (options.search_fields == 'standard' && options.extended_attribute_types.length > 0) || ( searched_attribute_fields.length > 0 ) ) && extendedPatronAttributes) { extended_attribute_codes_to_search = (searched_attribute_fields.length > 0) ? searched_attribute_fields : options.extended_attribute_types; extended_attribute_subquery_and = []; patterns.forEach(function (pattern, i) { Created attachment 161873 [details] [review] Bug 36025 Selenium test for the query parameters The test verifies that there is no clause for extended attributes in the patron search query when no patron attribute is searchable by default. Created attachment 161874 [details] [review] Bug 36025 Incorrect clause in patron search 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 [""] in the template patron-search.inc most likely due to a bug in DBIx::Class. 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' Created attachment 161914 [details] [review] Bug 36025: Selenium test for the query parameters The test verifies that there is no clause for extended attributes in the patron search query when no patron attribute is searchable by default. NC amended patch - tidied Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Created attachment 161915 [details] [review] Bug 36025: Incorrect clause in patron search 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 [""] in the template patron-search.inc most likely due to a bug in DBIx::Class. 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' Signed-off-by: Nick Clemens <nick@bywatersolutions.com> |