po: guard against reimportation

If po is imported twice, bad things happen. Guard against that.

I'm not sure what causes the double import; I saw it when websetup did a
wiki rebuild. Carp failed to show a backtrace for the second call to
import.
master
Joey Hess 2010-05-13 16:28:09 -04:00
parent 3f2f447cb5
commit 031da9c134
1 changed files with 14 additions and 12 deletions

View File

@ -51,18 +51,20 @@ sub import {
hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1);
hook(type => "formbuilder", id => "po", call => \&formbuilder);
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
inject(name => "IkiWiki::bestlink", call => \&mybestlink);
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
$origsubs{'targetpage'}=\&IkiWiki::targetpage;
inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
$origsubs{'urlto'}=\&IkiWiki::urlto;
inject(name => "IkiWiki::urlto", call => \&myurlto);
$origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
$origsubs{'rootpage'}=\&IkiWiki::rootpage;
inject(name => "IkiWiki::rootpage", call => \&myrootpage);
if (! %origsubs) {
$origsubs{'bestlink'}=\&IkiWiki::bestlink;
inject(name => "IkiWiki::bestlink", call => \&mybestlink);
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
$origsubs{'targetpage'}=\&IkiWiki::targetpage;
inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
$origsubs{'urlto'}=\&IkiWiki::urlto;
inject(name => "IkiWiki::urlto", call => \&myurlto);
$origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
$origsubs{'rootpage'}=\&IkiWiki::rootpage;
inject(name => "IkiWiki::rootpage", call => \&myrootpage);
}
}