User:AnomieBOT/source/tasks/TemplateSubster/Base.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TemplateSubster::Base: * Add some debugging. test.pl: * Allow specifying the debug level.
AnomieBOT (talk | contribs)
Updating published sources: TemplateSubster::Base: * Work around T14974 by reproducing the "after newline" environment when passing data to action=parse. d::Templates: * Indicate to the callback whether each template found by process_templates is located after a newline or not.
Line 144:
my $data=shift;
my $oname=shift;
my $nl=shift;
 
return undef unless exists($r->{"Template:$name"}) || exists($r->{$name});
Line 152 ⟶ 153:
}
}
my ($ret, $fatal) = $self->do_subst($api, $title, $oname, $name, $wikitext, $nl);
$fail = 1 if $fatal;
$remv{$name}=1 if defined( $ret );
Line 244 ⟶ 245:
 
sub do_subst {
my ($self,$api,$title,$oname,$name,$txt,$nl)=@_;
my $bot=$api->user;
my $sig=$self->{'sig'};
Line 259 ⟶ 260:
$itxt=~s/\}\}$/|subst=subst:}}/;
$itxt=~s/\Q$bot\E/$botr/g;
 
$itxt="T14974\n$itxt" if $nl; # Work around T14974
 
my $res=$api->query(action=>"parse", text=>$itxt, title=>$title, pst=>1, onlypst=>1);
Line 266 ⟶ 269:
}
my $otxt=$res->{'parse'}{'text'}{'*'};
$otxt=substr($otxt,7) if $nl;
if($otxt =~ /^\{\{subst:/ ) {
my $err = $otxt;