]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Hyperestraier_search_plug-in_defective.mdwn
3ccdf8e2c7fcdb15c1aeabaa503fc3927f03a4c5
[ikiwiki.git] / doc / bugs / Hyperestraier_search_plug-in_defective.mdwn
1 The map() function used in the hyperestraier search plug-in doesn't work as intended as ilustrated by this simple script:
2
3 #!/usr/bin/perl -w
4 use strict;
5 my @foo = (
6         [ qw/foo bar baz/ ],
7         [ qw/fee faa fum/ ],
8         );
9 # similar to current ikiwiki code (defective):
10 my @bar = map { "/path/to/$_" foreach @{$_} } @foo;
11 # this works:
12 #my @bar = map { map { "/path/to/$_" } @{$_} } @foo;
13 foreach (@bar) {
14         print "$_\n";
15 }
16
17 Expected output:
18 /path/to/foo
19 /path/to/bar
20 /path/to/baz
21 /path/to/fee
22 /path/to/faa
23 /path/to/fum
24
25 Current output:
26 Useless use of string in void context at perl-map.pl line 10.
27
28 The patch below fixes this issue:
29
30 --- IkiWiki/Plugin/search.pm.orig       Thu Feb  1 23:52:03 2007
31 +++ IkiWiki/Plugin/search.pm    Thu Feb  1 23:52:41 2007
32 @@ -64,8 +64,9 @@
33         debug(gettext("updating hyperestraier search index"));
34         estcmd("gather -cm -bc -cl -sd",
35                 map {
36 -                       Encode::encode_utf8($config{destdir}."/".$_)
37 -                               foreach @{$renderedfiles{pagename($_)}};
38 +                       map {
39 +                               Encode::encode_utf8($config{destdir}."/".$_)
40 +                       } @{$renderedfiles{pagename($_)}};
41                 } @_
42         );
43         estcfg();