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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TemplateTalkRedirectCreator: * Create talk redirects for Module sandbox subpages too.
AnomieBOT (talk | contribs)
Updating published sources: TemplateTalkRedirectCreator: * Update summary to mention /styles.css subpages.
 
(4 intermediate revisions by the same user not shown)
Line 14:
 
Create redirects for non-existing talk pages of certain pages:
* Template pages ending in "/doc", "/sandbox", "/testcases", "/TemplateData", or "/TemplateDatastyles.css"
* Module pages ending in "/doc", "/sandbox", or "/sandboxstyles.css"
 
=end metadata
Line 26:
use AnomieBOT::Task;
use Data::Dumper;
use Time::HiRes;
use vars qw/@ISA/;
@ISA=qw/AnomieBOT::Task/;
Line 35 ⟶ 36:
'%/testcases',
'%/TemplateData',
'%/styles.css',
],
'Module' => [
Line 40 ⟶ 42:
'%/sandbox',
# Not %/testcases though, those talk pages are often (ab)used to run the tests.
'%/styles.css',
],
);
Line 45 ⟶ 48:
sub mapTitle {
my $title = shift;
return $1 if $title=~m!^(Template talk:.+)/(?:doc|sandbox|testcases|TemplateData|styles\.css)$!;
return $1 if $title=~m!^(Module talk:.+)/(?:doc|sandbox|styles\.css)$!;
return undef;
}
Line 101 ⟶ 104:
# Load the list of redirects needing creation
my @rows;
my $t0 = Time::HiRes::time();
eval {
@rows = @{ $dbh->selectall_arrayref( qq{
Line 115 ⟶ 119:
return 300;
}
my $t1 = Time::HiRes::time();
$api->log( 'DB query took ' . ($t1-$t0) . ' seconds' );
last unless @rows;
 
Line 188 ⟶ 194:
}
 
my $txt = "#REDIRECT [[$target]]\n\n{{RcatRedirect category shell|\n{{R from remote talk page}}\n}}";
my $summary="Redirecting to [[$target]] to avoid decentralized discussion";