Content deleted Content added
Updating published sources: General: * New task, AFDMergeFromCleaner. |
Updating published sources: PUICloser: * Approved! AFDMergeFromCleaner: * Add handling of deleted pages * Clean up reporting code * Run to completion each time. |
||
Line 65:
my $screwup=' Errors? [[User:'.$api->user.'/shutoff/AFDMergeFromCleaner]]';
my $report='User:'.$api->user.'/Afd-mergefrom report';
my $endtime=time()+300;▼
# Get a list of templates redirecting to our targets
Line 82 ⟶ 79:
}
my %
my $ret=21600;
Line 89 ⟶ 87:
# Get the list of pages to check
my %q=(
list => 'embeddedin',
eititle => "Template:$template",
);
do {
Line 152 ⟶ 151:
# Now, query the found pages
my %
while(@from){
my @f=splice(@from, 0, 500);
Line 166 ⟶ 165:
if($t eq $subject){
$f=$norm{$f} if exists($norm{$f});
$
} else {
$
}
}▼
foreach (values %{$res->{'query'}{'pages'}}){
next unless exists($_->{'missing'});
# Missing pages should have the template removed, and
my $f=$_->{'title'};
$f=$norm{$f} if exists($norm{$f});
$remove{exists($norm{$f})?$norm{$f}:$f}=1;
$deleted{"$f>$subject"}="| [[:$f]] || [[:$subject]] || \n";
}
}
# Remove the
my $outtxt=$self->process_templates($intxt, sub {
return undef unless exists($templates{'Template:'.$_[0]});
Line 180 ⟶ 188:
($f=$_->{'value'})=~s/^\s+|\s+$//g if $_->{'name'} eq 1;
}
return exists($
});
Line 192 ⟶ 200:
next;
}
▲ }
▲ $ret=0; last MAINLOOP;
}
}
Line 202 ⟶ 205:
}
my $tok=$api->edittoken($report);
$self->warn("Task disabled: ".$tok->{'content'}."\n");▼
▲ return 300;
if(/^==\s*Redirected\s*==/){
foreach (split /\n/, $s){
next unless /^\| \[\[:([^]]+)\]\] \|\| \[\[:([^]]+)\]\] \|\| \[\[:([^]]+)\]\] \|\|/;▼
$redirected{"$1>$2>$3"}=$_;
} elsif(/^==\s*Deleted\s*==/){
foreach (split /\n/, $s){
next unless /^\| \[\[:([^]]+)\]\] \|\| \[\[:([^]]+)\]\] \|\|/;
}
}
}
▲ if($tok->{'code'} ne 'success'){
my $outtxt="== Redirected ==\n";
$outtxt.="The following table lists pages referred to by {{tl|afd-mergefrom}} are redirects to some page other than that with the {{tl|afd-mergefrom}}. Please correct the {{tl|afd-mergefrom}}, either by removing it (if the page was correctly merged elsewhere), undoing the incorrect redirection, or pointing it to the correct page. This table will be updated automatically.\n\n";
▲ $ret=60;
$outtxt.="{| class=\"wikitable sortable\"\n";
▲ last;
$outtxt.="! Page !! AFD merge to !! Redirect to !! Note\n";
▲ }
$outtxt.="|-\n";
▲ my $intxt=exists($tok->{'revisions'}[0]{'*'})?$tok->{'revisions'}[0]{'*'}:'';
$outtxt.=join("|-\n", sort values %redirected);
▲ foreach (split /\n/, $intxt){
$outtxt.="|}\n\n";
▲ next unless /^\| \[\[:([^]]+)\]\] \|\| \[\[:([^]]+)\]\] \|\| \[\[:([^]]+)\]\] \|\|/;
$outtxt.="== Deleted ==\n";
▲ $bad{"$1>$2>$3"}=$_;
$outtxt.="The following table lists deleted pages that were referred to by {{tl|afd-mergefrom}}; the offending {{tl|afd-mergefrom}} has already been removed. Please double-check whether the deletion was correct. If so, just remove the row from the table; if not, undelete the page and restore the {{tl|afd-mergefrom}}. This table will '''not''' be updated automatically.\n\n";
▲ }
$outtxt.="! Page !! AFD merge to !! Note\n";
$outtxt.="|-\n";
$outtxt.=join("|-\n", sort values %deleted);
$outtxt.="|}\n\n";
▲ }
}
▲ %bad=();
}
|