]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/Hyperestraier_search_plug-in_defective.mdwn
split off todo item for multiple dependency types
[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     
6     my @foo = (
7         [ qw/foo bar baz/ ],
8         [ qw/fee faa fum/ ],
9         );
10     
11     # similar to current ikiwiki code (defective):
12     my @bar = map { "/path/to/$_" foreach @{$_} } @foo;
13     
14     # this works:
15     #my @bar = map { map { "/path/to/$_" } @{$_} } @foo;
16     
17     foreach (@bar) {
18         print "$_\n";
19     }
20
21 Expected output:
22
23     /path/to/foo
24     /path/to/bar
25     /path/to/baz
26     /path/to/fee
27     /path/to/faa
28     /path/to/fum
29
30 Current output:
31
32     Useless use of string in void context at perl-map.pl line 10.
33
34 The patch below fixes this issue:
35
36     --- IkiWiki/Plugin/search.pm.orig       Thu Feb  1 23:52:03 2007
37     +++ IkiWiki/Plugin/search.pm    Thu Feb  1 23:52:41 2007
38     @@ -64,8 +64,9 @@
39             debug(gettext("updating hyperestraier search index"));
40             estcmd("gather -cm -bc -cl -sd",
41                     map {
42     -                       Encode::encode_utf8($config{destdir}."/".$_)
43     -                               foreach @{$renderedfiles{pagename($_)}};
44     +                       map {
45     +                               Encode::encode_utf8($config{destdir}."/".$_)
46     +                       } @{$renderedfiles{pagename($_)}};
47                     } @_
48             );
49             estcfg();
50
51 [[bugs/done]] ; thanks for the patch. Suprised it worked at all since the
52 bad code was added (did it?) --[[Joey]]
53
54 Thank you for accepting my patch. I can't see how it could ever have worked
55 with the previous code, no. --[[Brix|HenrikBrixAndersen]]