]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/search.pm
Merge commit 'smcv/master'
[ikiwiki.git] / IkiWiki / Plugin / search.pm
index 3ac4351979e7b96bd81c334d7d873cb40d612498..284f477fae5b32f63f9c9159f06c4af84dea2acd 100644 (file)
@@ -108,8 +108,14 @@ sub index (@) { #{{{
        if (! $stemmer) {
                my $langcode=$ENV{LANG} || "en";
                $langcode=~s/_.*//;
-               eval { $stemmer=Search::Xapian::Stem->new($langcode) };
-               if ($@) {
+
+               # This whitelist is here to work around a xapian bug (#486138)
+               my @whitelist=qw{da de en es fi fr hu it no pt ru ro sv tr};
+
+               if (grep { $_ eq $langcode } @whitelist) {
+                       $stemmer=Search::Xapian::Stem->new($langcode);
+               }
+               else {
                        $stemmer=Search::Xapian::Stem->new("english");
                }
        }
@@ -188,15 +194,19 @@ sub xapiandb () { #{{{
        return $db;
 } #}}}
 
+{
+my $setup=0;
 sub setupfiles () { #{{{
-       if (! -e $config{wikistatedir}."/xapian" || $config{rebuild}) {
+       if (! $setup and (! -e $config{wikistatedir}."/xapian" || $config{rebuild})) {
                writefile("omega.conf", $config{wikistatedir}."/xapian",
                        "database_dir .\n".
                        "template_dir ./templates\n");
                writefile("query", $config{wikistatedir}."/xapian/templates",
                        IkiWiki::misctemplate(gettext("search"),
                                readfile(IkiWiki::template_file("searchquery.tmpl"))));
+               $setup=1;
        }
 } #}}}
+}
 
 1