Bugzilla – Attachment 99054 Details for
Bug 24103
Add option to dump built search query to templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24103: Add option to dump search query to templates
Bug-24103-Add-option-to-dump-search-query-to-templ.patch (text/plain), 7.10 KB, created by
David Nind
on 2020-02-15 02:58:37 UTC
(
hide
)
Description:
Bug 24103: Add option to dump search query to templates
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-02-15 02:58:37 UTC
Size:
7.10 KB
patch
obsolete
>From 3c15dcee2303a14c1c771b47b0951f708d5aeab1 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 25 Nov 2019 14:58:00 +0000 >Subject: [PATCH] Bug 24103: Add option to dump search query to templates > >To test: >1 - Apply patch, update database >2 - Note new syspref 'DumpSearchQueryTemplate' >3 - Leave it off >4 - Enable DumpTemplateVariablesOpac and Staff >5 - Search on staff and opac >6 - View the source >7 - Search for 'search_query' - you shouldn't find it >8 - Enable the new pref >9 - Repeat, but you should find the query >10 - Test staff/opac search and advanced search, cataloguing search, authority search, authfinder search, adding to a basket form a new biblio >11 - All should work and show the query >12 - This will work under both ES and Zebra > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: David Nind <david@davidnind.com> >--- > authorities/auth_finder.pl | 1 + > authorities/authorities-home.pl | 1 + > catalogue/search.pl | 2 ++ > cataloguing/addbooks.pl | 3 +++ > .../Bug_24103_add_DumpSearchQueryTemplate_syspref.perl | 9 +++++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../intranet-tmpl/prog/en/modules/admin/preferences/logs.pref | 6 ++++++ > opac/opac-search.pl | 2 ++ > 8 files changed, 25 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/Bug_24103_add_DumpSearchQueryTemplate_syspref.perl > >diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl >index f017622678..208f076a13 100755 >--- a/authorities/auth_finder.pl >+++ b/authorities/auth_finder.pl >@@ -77,6 +77,7 @@ if ( $op eq "do_search" ) { > \@marclist, \@and_or, \@excluding, \@operator, > \@value, $authtypecode, $orderby > ); >+ $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate'); > my $offset = $startfrom * $resultsperpage; > my ( $results, $total ) = > $searcher->search_auth_compat( $search_query, $offset, >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index 29ee617173..76748aa66a 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -111,6 +111,7 @@ if ( $op eq "do_search" ) { > } > ); > >+ $template->param( search_query => $search_query ) if C4::Context->preference('DumpSearchQueryTemplate'); > $template->param( > csrf_token => Koha::Token->new->generate_csrf({ > session_id => scalar $query->cookie('CGISESSID'), >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 882a9eb052..6dcd6d891a 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -493,6 +493,8 @@ my $searcher = Koha::SearchEngine::Search->new( > = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits, > \@sort_by, $scan, $lang, { weighted_fields => !$cgi->param('advsearch'), whole_record => $whole_record }); > >+$template->param( search_query => $query ) if C4::Context->preference('DumpSearchQueryTemplate'); >+ > ## parse the query_cgi string and put it into a form suitable for <input>s > my @query_inputs; > my $scan_index_to_use; >diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index b9ed6ff874..f3b2e43fbb 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -83,6 +83,9 @@ if ($query) { > ( undef, $builtquery, undef, $query_cgi, undef, undef, undef, undef, undef, undef ) = > $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0, $lang ); > } >+ >+ $template->param( search_query => $builtquery ) if C4::Context->preference('DumpSearchQueryTemplate'); >+ > # find results > my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page); > >diff --git a/installer/data/mysql/atomicupdate/Bug_24103_add_DumpSearchQueryTemplate_syspref.perl b/installer/data/mysql/atomicupdate/Bug_24103_add_DumpSearchQueryTemplate_syspref.perl >new file mode 100644 >index 0000000000..da306863db >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_24103_add_DumpSearchQueryTemplate_syspref.perl >@@ -0,0 +1,9 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ >+ INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type) >+ VALUES ('DumpSearchQueryTemplate',0,'','Add the search query being passed to the search engine into the template for debugging','YesNo') >+ }); >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug XXXXX - add DumpSearchQueryTemplate syspref)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index cfa295e197..4af84eea7f 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -160,6 +160,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('DisplayLibraryFacets', 'holding', 'home|holding|both', 'Defines which library facets to display.', 'Choice'), > ('DisplayMultiPlaceHold','1','','Display the ability to place multiple holds or not','YesNo'), > ('DisplayOPACiconsXSLT','1','','If ON, displays the format, audience, and material type icons in XSLT MARC21 results and detail pages in the OPAC.','YesNo'), >+('DumpSearchQueryTemplate',0,'','Add the search query being passed to the search engine into the template for debugging','YesNo'), > ('DumpTemplateVarsIntranet', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.', 'YesNo'), > ('DumpTemplateVarsOpac', '0', NULL , 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.', 'YesNo'), > ('EasyAnalyticalRecords','0','','If on, display in the catalogue screens tools to easily setup analytical record relationships','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >index b3ca3c2433..1703230a17 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref >@@ -91,3 +91,9 @@ Logging: > on: Do > off: "Don't" > - dump all Template Toolkit variable to a comment in the html source for the OPAC. >+ - >+ - pref: DumpSearchQueryTemplate >+ choices: >+ on: Do >+ off: "Don't" >+ - dump search query as a template parameter, requires DumpTemplateVars[interface] to be visible. >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index f8a603f4af..61f3ea046f 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -572,6 +572,8 @@ if (C4::Context->preference('OpacSuppression')) { > } > ); > >+$template->param( search_query => $query ) if C4::Context->preference('DumpSearchQueryTemplate'); >+ > sub _input_cgi_parse { > my @elements; > my $query_cgi = shift or return @elements; >-- >2.11.0
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 24103
:
95792
|
98928
|
99023
|
99024
|
99054
|
99055
|
99137
|
99138