Bugzilla – Attachment 30709 Details for
Bug 12745
Add a sanity check for QueryParser configuration on about.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12745: Add a sanity check for QueryParser configuration on about.pl
Bug-12745-Add-a-sanity-check-for-QueryParser-confi.patch (text/plain), 6.53 KB, created by
Tomás Cohen Arazi (tcohen)
on 2014-08-11 15:59:37 UTC
(
hide
)
Description:
Bug 12745: Add a sanity check for QueryParser configuration on about.pl
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2014-08-11 15:59:37 UTC
Size:
6.53 KB
patch
obsolete
>From 01dcfa53f7295002f7eb93a50d7758fb58a728c1 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Mon, 11 Aug 2014 12:09:16 -0300 >Subject: [PATCH] Bug 12745: Add a sanity check for QueryParser configuration > on about.pl > >Currently there's no way for the user to know he has a bad QueryParser configuration. >Koha would just fallback to not using it. > >This patch adds a check for QueryParser configuration sanity in about.pl > >To test: >- Have UseQueryParser = "Don't try" >- Go to More > About Koha > System information >- No QueryParser-related warnings >- Set UseQueryParser = "Try" >- Go to More > About Koha > System information >- On a normal setup you shouldn't have any QueryParser-related warnings >- Edit your koha-conf.xml file and change the queryparser_config entry to a > non-existent filename. >- Reload More > About Koha > System information >=> SUCCESS: a warning message tells you the filename used, and says it failed. >- Now just delete the entry in koha-conf.xml >- Reload More > About Koha > System information >=> SUCCESS: a warning message tells you don't have the queryparser_entry in > your koha-conf.xml file. > Subtest: > a - The file /etc/koha/searchengine/queryparser.yaml exists: > => SUCCESS: a warning saying it used a fallback is shown > b - The file doesn't exist > => SUCCESS: Missing entry warning, plus a failure message for the fallback. >- Sign off :-D > >Regards >To+ > >Sponsored-by: Universidad Nacional de Cordoba >--- > about.pl | 29 ++++++++++++++++++++++++ > koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 23 ++++++++++++++++++- > 2 files changed, 51 insertions(+), 1 deletion(-) > >diff --git a/about.pl b/about.pl >index 8b9c1e7..b197cd3 100755 >--- a/about.pl >+++ b/about.pl >@@ -92,6 +92,35 @@ if ( ! defined C4::Context->config('zebra_auth_index_mode') ) { > }; > } > >+# Test QueryParser configuration sanity >+if ( C4::Context->preference( 'UseQueryParser' ) ) { >+ # Get the QueryParser configuration file name >+ my $queryparser_file = C4::Context->config( 'queryparser_config' ); >+ my $queryparser_fallback_file = '/etc/koha/searchengine/queryparser.yaml'; >+ # Check QueryParser is functional >+ my $QParser = C4::Context->queryparser(); >+ my $queryparser_error = {}; >+ if ( ! defined $QParser || ref($QParser) ne 'Koha::QueryParser::Driver::PQF' ) { >+ # Error initializing the QueryParser object >+ # Get the used queryparser.yaml file path to report the user >+ $queryparser_error->{ fallback } = ( defined $queryparser_file ) ? 0 : 1; >+ $queryparser_error->{ file } = ( defined $queryparser_file ) >+ ? $queryparser_file >+ : $queryparser_fallback_file; >+ # Report error data to the template >+ $template->param( QueryParserError => $queryparser_error ); >+ } else { >+ # Check for an absent queryparser_config entry in koha-conf.xml >+ if ( ! defined $queryparser_file ) { >+ # Not an error but a warning for the missing entry in koha-conf-xml >+ push @xml_config_warnings, { >+ error => 'queryparser_entry_missing', >+ file => $queryparser_fallback_file >+ }; >+ } >+ } >+} >+ > $template->param( > kohaVersion => $kohaVersion, > osVersion => $osVersion, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >index d434624..23b3bb0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >@@ -104,7 +104,8 @@ > <p>Please log in instead with a regular staff account. To create a staff account, create a library, a patron category 'Staff' and add a new patron. Then give this patron permissions from 'More' in the toolbar.</p> > [% END %] > <h2>Warnings regarding the system configuration</h2> >- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnNoActiveCurrency %] >+ [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || >+ warnNoActiveCurrency || QueryParserError %] > <table> > <caption>Preferences and parameters</caption> > [% IF (warnPrefBiblioAddsAuthorities) %] >@@ -119,6 +120,19 @@ > [% IF warnNoActiveCurrency %] > <tr><th scope="row"><b>Warning</b> </th><td>No active currency is defined. Please go to <a href="/cgi-bin/koha/admin/currency.pl">Administration > Currencies and exchange rates</a> and mark one currency as active.</td></tr> > [% END %] >+ [% IF QueryParserError %] >+ <tr><th scope="row"><b>Warning</b> </th><td> >+ You have set UseQueryParser but there was a problem inititializing QueryParser. >+ [% IF QueryParserError.fallback %] >+ The 'queryparser_config' entry is missing in your configuration file. >+ <strong>[% QueryParserError.file %]</strong> was used instead without success. >+ [% ELSE %] >+ The following configuration file was used without success: <strong>[% QueryParserError.file %]</strong>. >+ [% END %] >+ </td> >+ </tr> >+ [% END %] >+ > </table> > [% END %] > [% IF xml_config_warnings.size %] >@@ -129,6 +143,13 @@ > <tr><th scope="row"><b>Warning</b> </th><td>The <zebra_bib_index_mode> entry is missing in your configuration file. It should be set to <strong>dom</strong> or <strong>grs1</strong>. It will default to <strong>grs1</strong> but this could change in the future.</td></tr> > [% ELSIF config_entry.error == 'zebra_auth_index_mode_warn' %] > <tr><th scope="row"><b>Warning</b> </th><td>The <zebra_auth_index_mode> entry is missing in your configuration file. It should be set to <strong>dom</strong> or <strong>grs1</strong>. It will default to <strong>dom</strong> but this could change in the future.</td></tr> >+ [% ELSIF config_entry.error == 'queryparser_entry_missing' %] >+ <tr> >+ <th scope="row"><b>Warning</b></th> >+ <td>You have set UseQueryParser but the 'queryparser_config' entry is missing in your configuration >+ file. <strong>[% config_entry.file %]</strong> is used as a fallback. >+ </td> >+ </tr> > [% END %] > [% END %] > </table> >-- >1.9.1
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 12745
:
30709
|
30714
|
30847
|
30848
|
30849