avoid clobbering origsub if checkconfig runs more than once
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 23:15:25 +0000 (19:15 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 28 Aug 2009 23:15:25 +0000 (19:15 -0400)
checkconfig can run more than once in a single ikiwiki run if setup is
building wrappers. That clobbered the origsub value for bestlink, leading
to infinite recursion

IkiWiki/Plugin/po.pm

index 55c1c32c64f24c563b40d17e8249163b2d8b36c5..cde2ad4e3a7c4333285584c324525b754fe9d8c8 100644 (file)
@@ -152,8 +152,10 @@ sub checkconfig () {
                $config{po_link_to}='default';
        }
        unless ($config{po_link_to} eq 'default') {
-               $origsubs{'bestlink'}=\&IkiWiki::bestlink;
-               inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               if (! exists $origsubs{'bestlink'}) {
+                       $origsubs{'bestlink'}=\&IkiWiki::bestlink;
+                       inject(name => "IkiWiki::bestlink", call => \&mybestlink);
+               }
        }
 
        push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;