User:AnomieBOT/source/tasks/CommonsFileTemplateFixer.pm: Difference between revisions
Content deleted Content added
Updating published sources: CommonsFileTemplateFixer: * Approved for trial. * Needs a bunch of code to handle the conditions of the trial, though. |
Updating published sources: CommonsFileTemplateFixer: * Handle the possibility of too many categories to query with the edit token. AnomieBOT::API: * Fix adding of the xxlimit parameter for stuff queried with the edit token. Apparently this was broken since 2017, sigh. |
||
(2 intermediate revisions by the same user not shown) | |||
Line 201:
keys %goodcopycats,
);
my $qcatlimit = $api->paramLimit( 'query+categories', 'categories' );
if ( ! $self->{'iter'} ) {
$api->log( "Beginning " . ( $docopybotuntil ? 'bot-copy' : 'main' ) . " run" );
$self->{'broken'} = 0;
$self->{'iter'} = $api->iterator(
Line 213 ⟶ 215:
cllimit => 'max',
);
} else {
$api->log( "Continuing " . ( $docopybotuntil ? 'bot-copy' : 'main' ) . " run" );
}
Line 238 ⟶ 242:
next if ( $self->{'iter'}->iterval eq $r{'Template:Copy to Wikimedia Commons'} && ( $api->store->{"copyCheckTs:$title"} // 0 ) ge $copyCheckTs );
my $tok=$api->edittoken( $title, EditRedir => 1,
if ( $tok->{'code'} eq 'shutoff' ) {
$api->warn( "Task disabled: " . $tok->{'content'} . "\n" );
Line 368 ⟶ 372:
} elsif ( $tpl eq $r{'Template:Copy to Wikimedia Commons'} ) {
# Already on Commons?
my @dups = map { my $
if (
@dups = @{ $cache{'dups'}{$sha1} };▼
my $
push @summary, "remove {{Copy
formatversion => 2,▼
);▼
if ( $res->{'code'} ne 'success' ) {▼
$fail = 1;▼
return undef;▼
}▼
@dups = map { $_->{'title'} } @{ $res->{'query'}{'allimages'} };▼
$cache{'dups'}{$sha1} = \@dups;▼
}
if ( @dups ) {▼
$trialtasks{1} = 1;▼
if ( $isKeepLocal ) {▼
my
▲ push @summary, "remove {{Copy to Wikimedia Commons}}, on Commons as [[c:$d]] but tagged {{Keep local}} here";
$summary[$sidx] .= ' (and
$sidx = -1 if $hasNowCommons{$d} // 0;
my $
} else
$
$
▲ return undef;
# Check if it's already up for deletion on Commons.▼
my $cfile;▼
if ( defined( $cache{'info'}{$d} ) ) {▼
$cfile = $cache{'info'}{$d};▼
} else {▼
push @summary, "replace {{Now Commons}} with {{Nominated for deletion on Commons}} as [[c:$t]] is nominated for deletion";▼
$summary[$#summary] .= ' (and dedupe)' if $hasDelNomOnCommons{$t} // 0;▼
push @ret, "{{Now Commons|$d|date=" . strftime( '%-d %B %Y', gmtime ) . "|bot=" . $api->user . "}}";▼
}
▲
▲ } else {
▲
}
}
}
Line 533 ⟶ 517:
}
$api->log( "Finished " . ( $docopybotuntil ? 'bot-copy' : 'main' ) . " run" );
$self->{'iter'} = undef;
|