User:AnomieBOT/source/tasks/TemplateUnsubstifier.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TemplateUnsubster: * Don't add deprecated $N parameter.
AnomieBOT (talk | contribs)
Updating published sources: TemplateUnsubstifier: * Add some sanity checks to avoid trying to unsubstify redirects. Although there's no way that should be happening in the first place...
Line 130:
next unless $p->{'ns'} == 10; # Sanity check
next unless exists( $p->{'pageid'} ) && exists( $p->{'lastrevid'} ); # Page missing or invalid?
if ( exists( $p->{'redirect'} ) ) { # Redirect?
$api->warn( "How did we manage to get a redirect ($p->{title}) in here? Skipping it." );
next;
}
next if $p->{'lastrevid'} eq ( $api->store->{'lastrev ' . $p->{'pageid'}} // 0 );
push @templates, $p->{'title'};
Line 140 ⟶ 144:
my $endtime = time() + 300;
my @retry = ();
my $re = $api->redirect_regex();
while ( @templates ) {
return 0 if $api->halting;
Line 160 ⟶ 165:
(my $name = $title) =~ s/^Template://;
my $outtxt = undef;
 
# Sanity check
if ( $intxt =~ /$re/ ) {
$api->warn( "HELP: $title looks like a redirect, refusing to edit\n" );
goto skip;
}
 
# Split into template and noinclude parts, then process
Line 168 ⟶ 179:
} else {
$api->warn( "HELP: $title doesn't match the basic regular expression, refusing to edit\n" );
goto skip;
}
 
Line 197 ⟶ 209:
}
}
 
skip:
$api->store->{"lastrev $pageid"} = $revid;
$self->{'templates'} = [@templates, @retry];