Content deleted Content added
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>. |
Updating published sources: OnThisDayTagger: * Add to {{tl|ArticleHistory}} if that's present (and {{tl|OnThisDay}} isn't). |
||
Line 78:
my $screwup=' Errors? [[User:'.$api->user.'/shutoff/OnThisDayTagger]]';
$api->store->{'nextday'}=
my $starttime=time;
Line 616:
}
my %redir2=$api->redirects_to_resolved('Template:Article history');
# Update an existing template?▼
if(exists($redir2{''})){
$api->warn("Could not load list of redirects to Template:Article history: ".$redir2{''}{'error'}."\n");
return undef;
}
▲ # Update an existing OnThisDay template?
my $done=0;
$txt=$api->process_templates($txt, sub {
Line 655 ⟶ 661:
push @$params, "date$i=$date", "oldid$i=".$dates{$date};
$i++;
}
$done=1;
return "{{$oname|".join('|', @$params)."}}";
});
return $txt if $done;
# Update an existing ArticleHistory template?
$txt=$api->process_templates($txt, sub {
my $name=shift;
my $params=shift;
shift; # $wikitext
shift; # $data
my $oname=shift;
return unless exists($redir2{"Template:$name"});
# Find next unused number, and check which dates aren't already used
my %p=();
my $mx=1;
foreach (@$params){
$mx=$1 if(/^\s*otd(\d+)(?:date|oldid)\s*=/ && $mx < $1);
if(/^\s*(otd\d*date)\s*=\s*(\d{4}-\d{2}-\d{2})\s*$/){
$p{$1}=$2;
} elsif(/^\s*(otd\d*date)\s*=\s*((?i)$monthre)\s+(\d{1,2})(?:\s*,)?\s+(\d{4})\s*$/){
my $m; for($m=0; $m<@months; $m++){ last if lc($months[$m]) eq lc($2); }
$p{$1}=sprintf("%04d-%02d-%02d", $4, $m+1, $3);
} elsif(/^\s*(otd\d*date)\s*=\s*(\d{1,2})\s+((?i)$monthre)(?:\s*,)?\s+(\d{4})\s*$/){
my $m; for($m=0; $m<@months; $m++){ last if lc($months[$m]) eq lc($3); }
$p{$1}=sprintf("%04d-%02d-%02d", $4, $m+1, $2);
} elsif(/^\s*(otd\d*oldid)\s*=\s*(\d+)\s*$/){
$p{$1}=$2;
}
}
# Delete any already-listed dates
delete $dates{$p{"otddate"}} if(exists($p{"otddate"}) && exists($p{"otdoldid"}) && exists($dates{$p{"otddate"}}));
for(my $i=1; $i<=$mx; $i++){
delete $dates{$p{"otd${i}date"}} if(exists($p{"otd${i}date"}) && exists($p{"otd${i}oldid"}) && exists($dates{$p{"otd${i}date"}}));
}
# Add new parameters
foreach my $date (sort keys %dates){
++$mx;
push @$params, "otd${mx}date=$date", "otd${mx}oldid=".$dates{$date}."\n";
}
$done=1;
|