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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: DeletionSortingCleaner: * Better handle weird ways people list things: excess whitespace (note <code>process_templates</code> already converts underscores and such) and miscapitalization.
AnomieBOT (talk | contribs)
Updating published sources: DeletionSortingCleaner: * Yield like most other tasks do so it won't block other tasks so much.
Line 41:
my $class=shift;
my $self=$class->SUPER::new();
$self->{'pages'}=undef;
$self->{'lasttime'}=0;
$self->{'broken'}=0;
Line 90 ⟶ 91:
 
# Load list of deletion sorting subpages to process
if ( ! defined( $self->{'pages'} ) ) {
$res=$api->query(titles=>'Wikipedia:WikiProject Deletion sorting/Compact',prop=>'links',plnamespace=>4,pllimit=>'max');
if($res->{'code'} ne 'success'){
if($res->{'code'} ne 'success'){
$api->warn("Failed to get list of pages to process: ".$res->{'error'}."\n");
return 60;
}
my @ $self->{'pages'}=[ sort grep m!^Wikipedia:WikiProject Deletion sorting/!, map $_->{'title'}, @{(values %{$res->{'query'}{'pages'}})[0]{'links'}} ];
unless(@{$self->{'pages'}}){
$api->warn("No pages in list?");
$self->{'broken'}=1;
$api->store->{'broken'}=1;
return 3600;
}
}
my $endtime=time()+300;
 
while ( @{$self->{'pages'}} ) {
return 0 if $api->halting;
my $page = shift @{$self->{'pages'}};
 
for my $page (@pages){
# First, load the page to archive from. Allow for opting out using
# {{bots|optout=AnomieBOT/DeletionSortingCleaner}}
Line 317 ⟶ 324:
delete $api->store->{"archive $page"};
}
 
return 0 if time()>$endtime;
}
 
# Save checked revision
$self->{'pages'}=undef;
$self->{'lasttime'}=$starttime;
$self->{'broken'}=$broken;