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_setup", id => "po", call => \&formbuilder_setup, last => 1);
hook(type => "formbuilder", id => "po", call => \&formbuilder); hook(type => "formbuilder", id => "po", call => \&formbuilder);
$origsubs{'bestlink'}=\&IkiWiki::bestlink; if (! %origsubs) {
inject(name => "IkiWiki::bestlink", call => \&mybestlink); $origsubs{'bestlink'}=\&IkiWiki::bestlink;
$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; inject(name => "IkiWiki::bestlink", call => \&mybestlink);
inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath;
$origsubs{'targetpage'}=\&IkiWiki::targetpage; inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
inject(name => "IkiWiki::targetpage", call => \&mytargetpage); $origsubs{'targetpage'}=\&IkiWiki::targetpage;
$origsubs{'urlto'}=\&IkiWiki::urlto; inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
inject(name => "IkiWiki::urlto", call => \&myurlto); $origsubs{'urlto'}=\&IkiWiki::urlto;
$origsubs{'cgiurl'}=\&IkiWiki::cgiurl; inject(name => "IkiWiki::urlto", call => \&myurlto);
inject(name => "IkiWiki::cgiurl", call => \&mycgiurl); $origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
$origsubs{'rootpage'}=\&IkiWiki::rootpage; inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
inject(name => "IkiWiki::rootpage", call => \&myrootpage); $origsubs{'rootpage'}=\&IkiWiki::rootpage;
inject(name => "IkiWiki::rootpage", call => \&myrootpage);
}
} }