From 56f95c069b3e6bdf192dc358a3140479cd9d2650 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 5 May 2016 16:58:06 +0100 Subject: [PATCH] Bug 16455: Remove the "Too late to run INIT block" from C4::Tags Content-Type: text/plain; charset=utf-8 The pref TagsExternalDictionary is used to tell Lingua::Ispell to use an other dictionary, different from the default one (/usr/bin/ispell). To do so we need to set $Lingua::Ispell::path to the expected path. It's currently done in the INIT block. If you try to use C4::Tags, you will get the famous "Too late to run INIT block at C4/Tags.pm line 74." warning. Plack use the INIT block to load functions at run time, when we are using C4::Tags when hitting a pl script, the compilation phase is finished and it's "too late to run INIT block" from C4::Tags. I do not really know if it has an impact on the behavior of Lingua::Ispell (i.e. is the path redefined?), but I know that this INIT block is not executed when we want. Test plan: under Plack, - hit /cgi-bin/koha/opac-search.pl and confirm that the warning does no longer appears - Use another dictionnary (??), fill TagsExternalDictionary with its path and confirm that it is used by the tags approval system Signed-off-by: Chris Cormack Signed-off-by: Marcel de Rooy --- C4/Tags.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/C4/Tags.pm b/C4/Tags.pm index 33d77d4..c964bc1 100644 --- a/C4/Tags.pm +++ b/C4/Tags.pm @@ -57,7 +57,9 @@ BEGIN { } if ($ext_dict) { require Lingua::Ispell; - import Lingua::Ispell qw(spellcheck add_word_lc save_dictionary); + import Lingua::Ispell qw(spellcheck add_word_lc); + $Lingua::Ispell::path = $ext_dict; + $debug and print STDERR "\$Lingua::Ispell::path = $Lingua::Ispell::path\n"; } } @@ -67,12 +69,6 @@ More verose debugging messages are sent in the presence of non-zero $ENV{"DEBUG" =cut -INIT { - my $ext_dict = C4::Context->preference('TagsExternalDictionary'); - $ext_dict and $Lingua::Ispell::path = $ext_dict; - $debug and print STDERR "\$Lingua::Ispell::path = $Lingua::Ispell::path\n"; -} - sub get_filters { my $query = "SELECT * FROM tags_filters "; my ($sth); -- 1.7.10.4