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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader: * Sort directory pages by last modified date. * Use <nowiki><syntaxhighlight></nowiki> instead of <nowiki><source></nowiki>. d::NoWiki: * Add support for <nowiki><syntaxhighlight></nowiki>. General: * Vario
AnomieBOT (talk | contribs)
Updating published sources: General: * Update for the addition of 'rvslots'. DatedCategoryDeleterTest: * Disable. It's clear that task won't be needed. BrokenRedirectDeleter: * Handle pages with newlines before the <code>#REDIRECT</code>.
 
(5 intermediate revisions by 3 users not shown)
Line 64:
my $re=$api->redirect_regex();
my $base=$api->user.'/req/';
my $iter=$api->iterator(generator=>'allpages',gapprefix=>$base,gapnamespace=>2,gapfilterredir=>'redirects',prop=>'info|revisions',rvprop=>'content',rvslots=>'main');
my @whine=();
while(my $page=$iter->next){
Line 72:
}
 
my $txt=$page->{'revisions'}[0]{'slots'}{'main'}{'*'};
next unless $txt=~/$re\[\[([^]#]+)#([^]]+)\]\]/;
my ($title,$anchor)=($1,$2);
Line 88:
# because the encoded anchors returned in "sections" varies based on
# server settings. Note this doesn't support {{anchor}} or the like.
$anchorencanchor =~ s/^XXX_\{/&#x7B;/g;
$res=$api->query(action=>'parse',title=>$title,text=>"__TOC__\n== XXX $anchor ==\n\n{{:$title}}",prop=>'sections');
if($res->{'code'} ne 'success'){
Line 95 ⟶ 96:
my @s=map $_->{'anchor'}, @{$res->{'parse'}{'sections'}};
my $anchorenc=shift @s; $anchorenc=~s/^XXX_//; # Pull out the dummy
$anchorenc=~s/^XXX_//;
next if grep($_ eq $anchorenc, @s);
 
Line 110:
}
if(exists($res->{'query-continue'})){
$q{'rvstartidrvcontinue'}=$res->{'query-continue'}{'revisions'}{'rvstartidrvcontinue'};
} else {
delete $q{'rvstartidrvcontinue'};
}
 
Line 140:
last if defined($newtitle);
}
} while(!defined($newtitle) && exists($q{'rvstartidrvcontinue'}));
 
if(defined($newtitle)){