From 207413828318c4515053c7043dadb5ee934f3b2f 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Brendan Gallagher (cherry picked from commit 7d916c380a03904c47035f189d1ee666f00d9a11) Signed-off-by: Frédéric Demians (cherry picked from commit 6ff159e214a2ebf904ff7f1b77f0f75162f8afe8) Signed-off-by: Julian Maurice --- C4/Tags.pm | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/C4/Tags.pm b/C4/Tags.pm index 5f1ae34712..6b55530060 100644 --- a/C4/Tags.pm +++ b/C4/Tags.pm @@ -58,7 +58,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"; } } @@ -68,12 +70,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); -- 2.39.5