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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Stop updating EDITREQTable, so it can be turned into something vaguely resembling a disambiguation page.
AnomieBOT (talk | contribs)
Updating published sources: PERTableUpdater: * Improve logging of bad regexes from the title blacklists ** Include page and line number in a standard format in all messages. ** Include the actual error when skipping bad regexes. ** Log warnings properly instead of letting Perl dump them to the console every run. ** Always log when running in testing (noedit) mode.
Line 116:
return 60;
}
my $ln = 0;
for my $line (split /\r?\n/, $tb->{'content'}){
$ln++;
my $re=$line;
my %opts=();
Line 139 ⟶ 141:
my $tmp = $re;
$re=~s#(?<!\\[a-zA-Z])(?<!\\)\{(?!\d+(?:,\d*)?})#\\{#g;
$self->warnBadRegex( $api, "$page:$ln: Escaped left-braces in regex (old): $tmp" ) if $tmp ne $re;
$self->warnBadRegex( $api, "$page:$ln: Escaped left-braces in regex (new): $re" ) if $tmp ne $re;
 
# Validate each line, in case someone screws up the blacklist page
eval {
no warnings;
qr/^(?:$re)$/si;
};
if ( $@ ) {
$self->warnBadRegex( $api, "$page:$ln: Ignoring bad regex '$re' in: $page@\n");
next;
}
 
# Log non-fatal warnings too.
eval {
use warnings FATAL => 'all';
qr/^(?:$re)$/si;
};
if ( $@ ) {
$self->warnBadRegex( $api, "$page:$ln: Warning: $@\n");
}
 
Line 470 ⟶ 482:
my ($self, $api, $msg) = @_;
 
$msg =~ s/\s+$//;
my $warned = $api->store->{'warnedBadRegex'};
my $file = __FILE__;
return if exists( $warned->{$msg} );
$warned->{$msg} =~ 1s/ at \Q$file\E line \d+\.$//;
 
$api->store->{'warnedBadRegex'} = $warned;
if ( ! defined( $api->warn({'noedit'} $msg) ); {
my $warned = $api->store->{'warnedBadRegex'};
return if exists( $warned->{$msg} );
$warned->{$msg} = 1;
$api->store->{'warnedBadRegex'} = $warned;
}
 
$api->warn( "$msg\n" );
}