30 require_once __DIR__ .
'/Maintenance.php';
39 parent::__construct();
41 $this->
addOption(
'async',
'Don\'t fix anything directly, just queue the jobs' );
42 $this->
addOption(
'title',
'Fix only redirects pointing to this page',
false,
true );
43 $this->
addOption(
'dry-run',
'Perform a dry run, fix nothing' );
68 'pa.page_namespace AS pa_namespace',
69 'pa.page_title AS pa_title',
70 'pb.page_namespace AS pb_namespace',
71 'pb.page_title AS pb_title',
74 'rd_from = pa.page_id',
75 'rd_namespace = pb.page_namespace',
76 'rd_title = pb.page_title',
78 'rd_interwiki IS NULL OR rd_interwiki = ' .
$dbr->addQuotes(
'' ),
79 'pb.page_is_redirect' => 1,
83 $conds[
'pb.page_namespace'] =
$title->getNamespace();
84 $conds[
'pb.page_title'] =
$title->getDBkey();
88 $res =
$dbr->select( $tables, $fields, $conds, __METHOD__ );
90 if ( !
$res->numRows() ) {
91 $this->
output(
"No double redirects found.\n" );
97 $processedTitles =
"\n";
99 foreach (
$res as $row ) {
103 $processedTitles .=
"* [[$titleA]]\n";
106 'reason' =>
'maintenance',
107 'redirTitle' => $titleB->getPrefixedDBkey()
113 $this->
error(
"Error fixing " . $titleA->getPrefixedText()
114 .
": " .
$job->getLastError() .
"\n" );
118 if ( count( $jobs ) > DoubleRedirectJob::MAX_DR_JOBS_COUNTER ) {
124 if ( ++$n % 100 == 0 ) {
125 $this->
output(
"$n...\n" );
129 if ( count( $jobs ) ) {
132 $this->
output(
"$n double redirects processed" . $processedTitles .
"\n" );
135 protected function queueJobs( $jobs, $dryrun =
false ) {
136 $this->
output(
"Queuing batch of " . count( $jobs ) .
" double redirects.\n" );
137 MediaWikiServices::getInstance()->getJobQueueGroup()->push( $dryrun ? [] : $jobs );
142 require_once RUN_MAINTENANCE_IF_MAIN;
Job to fix double redirects after moving a page.
Maintenance script that fixes double redirects.
queueJobs( $jobs, $dryrun=false)
__construct()
Default constructor.
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option was set.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
if(count( $args)< 1) $job