MediaWiki  master
namespaceDupes.php
Go to the documentation of this file.
1 <?php
27 require_once __DIR__ . '/Maintenance.php';
28 
35 
42 class NamespaceDupes extends Maintenance {
43 
47  protected $db;
48 
53  private $resolvablePages = 0;
54 
59  private $totalPages = 0;
60 
65  private $resolvableLinks = 0;
66 
71  private $totalLinks = 0;
72 
78  private $deletedLinks = 0;
79 
80  public function __construct() {
81  parent::__construct();
82  $this->addDescription( 'Find and fix pages affected by namespace addition/removal' );
83  $this->addOption( 'fix', 'Attempt to automatically fix errors and delete broken links' );
84  $this->addOption( 'merge', "Instead of renaming conflicts, do a history merge with " .
85  "the correct title" );
86  $this->addOption( 'add-suffix', "Dupes will be renamed with correct namespace with " .
87  "<text> appended after the article name", false, true );
88  $this->addOption( 'add-prefix', "Dupes will be renamed with correct namespace with " .
89  "<text> prepended before the article name", false, true );
90  $this->addOption( 'source-pseudo-namespace', "Move all pages with the given source " .
91  "prefix (with an implied colon following it). If --dest-namespace is not specified, " .
92  "the colon will be replaced with a hyphen.",
93  false, true );
94  $this->addOption( 'dest-namespace', "In combination with --source-pseudo-namespace, " .
95  "specify the namespace ID of the destination.", false, true );
96  $this->addOption( 'move-talk', "If this is specified, pages in the Talk namespace that " .
97  "begin with a conflicting prefix will be renamed, for example " .
98  "Talk:File:Foo -> File_Talk:Foo" );
99  }
100 
101  public function execute() {
102  $options = [
103  'fix' => $this->hasOption( 'fix' ),
104  'merge' => $this->hasOption( 'merge' ),
105  'add-suffix' => $this->getOption( 'add-suffix', '' ),
106  'add-prefix' => $this->getOption( 'add-prefix', '' ),
107  'move-talk' => $this->hasOption( 'move-talk' ),
108  'source-pseudo-namespace' => $this->getOption( 'source-pseudo-namespace', '' ),
109  'dest-namespace' => intval( $this->getOption( 'dest-namespace', 0 ) )
110  ];
111 
112  if ( $options['source-pseudo-namespace'] !== '' ) {
113  $retval = $this->checkPrefix( $options );
114  } else {
115  $retval = $this->checkAll( $options );
116  }
117 
118  if ( $retval ) {
119  $this->output( "\nLooks good!\n" );
120  } else {
121  $this->output( "\nOh noeees\n" );
122  }
123  }
124 
132  private function checkAll( $options ) {
133  $contLang = MediaWikiServices::getInstance()->getContentLanguage();
134  $spaces = [];
135 
136  // List interwikis first, so they'll be overridden
137  // by any conflicting local namespaces.
138  foreach ( $this->getInterwikiList() as $prefix ) {
139  $name = $contLang->ucfirst( $prefix );
140  $spaces[$name] = 0;
141  }
142 
143  // Now pull in all canonical and alias namespaces...
144  foreach (
145  MediaWikiServices::getInstance()->getNamespaceInfo()->getCanonicalNamespaces()
146  as $ns => $name
147  ) {
148  // This includes $wgExtraNamespaces
149  if ( $name !== '' ) {
150  $spaces[$name] = $ns;
151  }
152  }
153  foreach ( $contLang->getNamespaces() as $ns => $name ) {
154  if ( $name !== '' ) {
155  $spaces[$name] = $ns;
156  }
157  }
158  foreach ( $contLang->getNamespaceAliases() as $name => $ns ) {
159  $spaces[$name] = $ns;
160  }
161 
162  // We'll need to check for lowercase keys as well,
163  // since we're doing case-sensitive searches in the db.
164  $capitalLinks = $this->getConfig()->get( 'CapitalLinks' );
165  foreach ( $spaces as $name => $ns ) {
166  $moreNames = [];
167  $moreNames[] = $contLang->uc( $name );
168  $moreNames[] = $contLang->ucfirst( $contLang->lc( $name ) );
169  $moreNames[] = $contLang->ucwords( $name );
170  $moreNames[] = $contLang->ucwords( $contLang->lc( $name ) );
171  $moreNames[] = $contLang->ucwordbreaks( $name );
172  $moreNames[] = $contLang->ucwordbreaks( $contLang->lc( $name ) );
173  if ( !$capitalLinks ) {
174  foreach ( $moreNames as $altName ) {
175  $moreNames[] = $contLang->lcfirst( $altName );
176  }
177  $moreNames[] = $contLang->lcfirst( $name );
178  }
179  foreach ( array_unique( $moreNames ) as $altName ) {
180  if ( $altName !== $name ) {
181  $spaces[$altName] = $ns;
182  }
183  }
184  }
185 
186  // Sort by namespace index, and if there are two with the same index,
187  // break the tie by sorting by name
188  $origSpaces = $spaces;
189  uksort( $spaces, static function ( $a, $b ) use ( $origSpaces ) {
190  return $origSpaces[$a] <=> $origSpaces[$b]
191  ?: $a <=> $b;
192  } );
193 
194  $ok = true;
195  foreach ( $spaces as $name => $ns ) {
196  $ok = $this->checkNamespace( $ns, $name, $options ) && $ok;
197  }
198 
199  $this->output(
200  "{$this->totalPages} pages to fix, " .
201  "{$this->resolvablePages} were resolvable.\n\n"
202  );
203 
204  foreach ( $spaces as $name => $ns ) {
205  if ( $ns != 0 ) {
206  /* Fix up link destinations for non-interwiki links only.
207  *
208  * For example if a page has [[Foo:Bar]] and then a Foo namespace
209  * is introduced, pagelinks needs to be updated to have
210  * page_namespace = NS_FOO.
211  *
212  * If instead an interwiki prefix was introduced called "Foo",
213  * the link should instead be moved to the iwlinks table. If a new
214  * language is introduced called "Foo", or if there is a pagelink
215  * [[fr:Bar]] when interlanguage magic links are turned on, the
216  * link would have to be moved to the langlinks table. Let's put
217  * those cases in the too-hard basket for now. The consequences are
218  * not especially severe.
219  * @fixme Handle interwiki links, and pagelinks to Category:, File:
220  * which probably need reparsing.
221  */
222 
223  $this->checkLinkTable( 'pagelinks', 'pl', $ns, $name, $options );
224  $this->checkLinkTable( 'templatelinks', 'tl', $ns, $name, $options );
225 
226  // The redirect table has interwiki links randomly mixed in, we
227  // need to filter those out. For example [[w:Foo:Bar]] would
228  // have rd_interwiki=w and rd_namespace=0, which would match the
229  // query for a conflicting namespace "Foo" if filtering wasn't done.
230  $this->checkLinkTable( 'redirect', 'rd', $ns, $name, $options,
231  [ 'rd_interwiki' => null ] );
232  $this->checkLinkTable( 'redirect', 'rd', $ns, $name, $options,
233  [ 'rd_interwiki' => '' ] );
234  }
235  }
236 
237  $this->output(
238  "{$this->totalLinks} links to fix, " .
239  "{$this->resolvableLinks} were resolvable, " .
240  "{$this->deletedLinks} were deleted.\n"
241  );
242 
243  return $ok;
244  }
245 
249  private function getInterwikiList() {
250  $result = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes();
251  return array_column( $result, 'iw_prefix' );
252  }
253 
262  private function checkNamespace( $ns, $name, $options ) {
263  $targets = $this->getTargetList( $ns, $name, $options );
264  $count = $targets->numRows();
265  $this->totalPages += $count;
266  if ( $count == 0 ) {
267  return true;
268  }
269 
270  $dryRunNote = $options['fix'] ? '' : ' DRY RUN ONLY';
271 
272  $ok = true;
273  foreach ( $targets as $row ) {
274  // Find the new title and determine the action to take
275 
276  $newTitle = $this->getDestinationTitle(
277  $ns, $name, $row->page_namespace, $row->page_title );
278  $logStatus = false;
279  if ( !$newTitle ) {
280  if ( $options['add-prefix'] == '' && $options['add-suffix'] == '' ) {
281  $logStatus = 'invalid title and --add-prefix not specified';
282  $action = 'abort';
283  } else {
284  $action = 'alternate';
285  }
286  } elseif ( $newTitle->exists() ) {
287  if ( $options['merge'] ) {
288  if ( $this->canMerge( $row->page_id, $newTitle, $logStatus ) ) {
289  $action = 'merge';
290  } else {
291  $action = 'abort';
292  }
293  } elseif ( $options['add-prefix'] == '' && $options['add-suffix'] == '' ) {
294  $action = 'abort';
295  $logStatus = 'dest title exists and --add-prefix not specified';
296  } else {
297  $action = 'alternate';
298  }
299  } else {
300  $action = 'move';
301  $logStatus = 'no conflict';
302  }
303  if ( $action === 'alternate' ) {
304  [ $ns, $dbk ] = $this->getDestination( $ns, $name, $row->page_namespace,
305  $row->page_title );
306  $newTitle = $this->getAlternateTitle( $ns, $dbk, $options );
307  if ( !$newTitle ) {
308  $action = 'abort';
309  $logStatus = 'alternate title is invalid';
310  } elseif ( $newTitle->exists() ) {
311  $action = 'abort';
312  $logStatus = 'alternate title conflicts';
313  } else {
314  $action = 'move';
315  $logStatus = 'alternate';
316  }
317  }
318 
319  // Take the action or log a dry run message
320 
321  $logTitle = "id={$row->page_id} ns={$row->page_namespace} dbk={$row->page_title}";
322  $pageOK = true;
323 
324  switch ( $action ) {
325  case 'abort':
326  $this->output( "$logTitle *** $logStatus\n" );
327  $pageOK = false;
328  break;
329  case 'move':
330  $this->output( "$logTitle -> " .
331  $newTitle->getPrefixedDBkey() . " ($logStatus)$dryRunNote\n" );
332 
333  if ( $options['fix'] ) {
334  $pageOK = $this->movePage( $row->page_id, $newTitle );
335  }
336  break;
337  case 'merge':
338  $this->output( "$logTitle => " .
339  $newTitle->getPrefixedDBkey() . " (merge)$dryRunNote\n" );
340 
341  if ( $options['fix'] ) {
342  $pageOK = $this->mergePage( $row, $newTitle );
343  }
344  break;
345  }
346 
347  if ( $pageOK ) {
348  $this->resolvablePages++;
349  } else {
350  $ok = false;
351  }
352  }
353 
354  return $ok;
355  }
356 
366  private function checkLinkTable( $table, $fieldPrefix, $ns, $name, $options,
367  $extraConds = []
368  ) {
369  $dbw = $this->getDB( DB_PRIMARY );
370 
371  $batchConds = [];
372  $fromField = "{$fieldPrefix}_from";
373  $namespaceField = "{$fieldPrefix}_namespace";
374  $titleField = "{$fieldPrefix}_title";
375  $batchSize = 500;
376  $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
377  while ( true ) {
378  $res = $dbw->select(
379  $table,
380  [ $fromField, $namespaceField, $titleField ],
381  array_merge(
382  $batchConds,
383  $extraConds,
384  [
385  $namespaceField => 0,
386  $titleField . $dbw->buildLike( "$name:", $dbw->anyString() )
387  ]
388  ),
389  __METHOD__,
390  [
391  'ORDER BY' => [ $titleField, $fromField ],
392  'LIMIT' => $batchSize
393  ]
394  );
395 
396  if ( $res->numRows() == 0 ) {
397  break;
398  }
399 
400  $rowsToDeleteIfStillExists = [];
401 
402  foreach ( $res as $row ) {
403  $logTitle = "from={$row->$fromField} ns={$row->$namespaceField} " .
404  "dbk={$row->$titleField}";
405  $destTitle = $this->getDestinationTitle(
406  $ns, $name, $row->$namespaceField, $row->$titleField );
407  $this->totalLinks++;
408  if ( !$destTitle ) {
409  $this->output( "$table $logTitle *** INVALID\n" );
410  continue;
411  }
412  $this->resolvableLinks++;
413  if ( !$options['fix'] ) {
414  $this->output( "$table $logTitle -> " .
415  $destTitle->getPrefixedDBkey() . " DRY RUN\n" );
416  continue;
417  }
418 
419  $dbw->update( $table,
420  // SET
421  [
422  $namespaceField => $destTitle->getNamespace(),
423  $titleField => $destTitle->getDBkey()
424  ],
425  // WHERE
426  [
427  $namespaceField => 0,
428  $titleField => $row->$titleField,
429  $fromField => $row->$fromField
430  ],
431  __METHOD__,
432  [ 'IGNORE' ]
433  );
434 
435  $rowsToDeleteIfStillExists[] = $dbw->makeList(
436  [
437  $fromField => $row->$fromField,
438  $namespaceField => $row->$namespaceField,
439  $titleField => $row->$titleField,
440  ],
442  );
443 
444  $this->output( "$table $logTitle -> " .
445  $destTitle->getPrefixedDBkey() . "\n"
446  );
447  }
448 
449  if ( $options['fix'] && count( $rowsToDeleteIfStillExists ) > 0 ) {
450  $dbw->delete(
451  $table,
452  $dbw->makeList( $rowsToDeleteIfStillExists, IDatabase::LIST_OR ),
453  __METHOD__
454  );
455 
456  $this->deletedLinks += $dbw->affectedRows();
457  $this->resolvableLinks -= $dbw->affectedRows();
458  }
459 
460  $encLastTitle = $dbw->addQuotes( $row->$titleField );
461  $encLastFrom = $dbw->addQuotes( $row->$fromField );
462 
463  $batchConds = [
464  "$titleField > $encLastTitle " .
465  "OR ($titleField = $encLastTitle AND $fromField > $encLastFrom)"
466  ];
467 
468  $lbFactory->waitForReplication();
469  }
470  }
471 
479  private function checkPrefix( $options ) {
480  $prefix = $options['source-pseudo-namespace'];
481  $ns = $options['dest-namespace'];
482  $this->output( "Checking prefix \"$prefix\" vs namespace $ns\n" );
483 
484  return $this->checkNamespace( $ns, $prefix, $options );
485  }
486 
497  private function getTargetList( $ns, $name, $options ) {
498  $dbw = $this->getDB( DB_PRIMARY );
499 
500  if (
501  $options['move-talk'] &&
502  MediaWikiServices::getInstance()->getNamespaceInfo()->isSubject( $ns )
503  ) {
504  $checkNamespaces = [ NS_MAIN, NS_TALK ];
505  } else {
506  $checkNamespaces = NS_MAIN;
507  }
508 
509  return $dbw->select( 'page',
510  [
511  'page_id',
512  'page_title',
513  'page_namespace',
514  ],
515  [
516  'page_namespace' => $checkNamespaces,
517  'page_title' . $dbw->buildLike( "$name:", $dbw->anyString() ),
518  ],
519  __METHOD__
520  );
521  }
522 
531  private function getDestination( $ns, $name, $sourceNs, $sourceDbk ) {
532  $dbk = substr( $sourceDbk, strlen( "$name:" ) );
533  if ( $ns == 0 ) {
534  // An interwiki; try an alternate encoding with '-' for ':'
535  $dbk = "$name-" . $dbk;
536  }
537  $destNS = $ns;
538  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
539  if ( $sourceNs == NS_TALK && $nsInfo->isSubject( $ns ) ) {
540  // This is an associated talk page moved with the --move-talk feature.
541  $destNS = $nsInfo->getTalk( $destNS );
542  }
543  return [ $destNS, $dbk ];
544  }
545 
554  private function getDestinationTitle( $ns, $name, $sourceNs, $sourceDbk ) {
555  [ $destNS, $dbk ] = $this->getDestination( $ns, $name, $sourceNs, $sourceDbk );
556  $newTitle = Title::makeTitleSafe( $destNS, $dbk );
557  if ( !$newTitle || !$newTitle->canExist() ) {
558  return false;
559  }
560  return $newTitle;
561  }
562 
572  private function getAlternateTitle( $ns, $dbk, $options ) {
573  $prefix = $options['add-prefix'];
574  $suffix = $options['add-suffix'];
575  if ( $prefix == '' && $suffix == '' ) {
576  return false;
577  }
578  $newDbk = $prefix . $dbk . $suffix;
579  return Title::makeTitleSafe( $ns, $newDbk );
580  }
581 
589  private function movePage( $id, LinkTarget $newLinkTarget ) {
590  $dbw = $this->getDB( DB_PRIMARY );
591 
592  $dbw->update( 'page',
593  [
594  "page_namespace" => $newLinkTarget->getNamespace(),
595  "page_title" => $newLinkTarget->getDBkey(),
596  ],
597  [
598  "page_id" => $id,
599  ],
600  __METHOD__
601  );
602 
603  // Update *_from_namespace in links tables
604  $fromNamespaceTables = [
605  [ 'pagelinks', 'pl' ],
606  [ 'templatelinks', 'tl' ],
607  [ 'imagelinks', 'il' ]
608  ];
609  foreach ( $fromNamespaceTables as [ $table, $fieldPrefix ] ) {
610  $dbw->update( $table,
611  // SET
612  [ "{$fieldPrefix}_from_namespace" => $newLinkTarget->getNamespace() ],
613  // WHERE
614  [ "{$fieldPrefix}_from" => $id ],
615  __METHOD__
616  );
617  }
618 
619  return true;
620  }
621 
634  private function canMerge( $id, LinkTarget $linkTarget, &$logStatus ) {
635  $revisionLookup = MediaWikiServices::getInstance()->getRevisionLookup();
636  $latestDest = $revisionLookup->getRevisionByTitle( $linkTarget, 0,
637  IDBAccessObject::READ_LATEST );
638  $latestSource = $revisionLookup->getRevisionByPageId( $id, 0,
639  IDBAccessObject::READ_LATEST );
640  if ( $latestSource->getTimestamp() > $latestDest->getTimestamp() ) {
641  $logStatus = 'cannot merge since source is later';
642  return false;
643  } else {
644  return true;
645  }
646  }
647 
655  private function mergePage( $row, Title $newTitle ) {
656  $dbw = $this->getDB( DB_PRIMARY );
657 
658  $id = $row->page_id;
659 
660  // Construct the WikiPage object we will need later, while the
661  // page_id still exists. Note that this cannot use makeTitleSafe(),
662  // we are deliberately constructing an invalid title.
663  $sourceTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
664  $sourceTitle->resetArticleID( $id );
665  $wikiPage = new WikiPage( $sourceTitle );
666  $wikiPage->loadPageData( WikiPage::READ_LATEST );
667 
668  $destId = $newTitle->getArticleID();
669  $this->beginTransaction( $dbw, __METHOD__ );
670  $dbw->update( 'revision',
671  // SET
672  [ 'rev_page' => $destId ],
673  // WHERE
674  [ 'rev_page' => $id ],
675  __METHOD__
676  );
677 
678  $dbw->delete( 'page', [ 'page_id' => $id ], __METHOD__ );
679 
680  $this->commitTransaction( $dbw, __METHOD__ );
681 
682  /* Call LinksDeletionUpdate to delete outgoing links from the old title,
683  * and update category counts.
684  *
685  * Calling external code with a fake broken Title is a fairly dubious
686  * idea. It's necessary because it's quite a lot of code to duplicate,
687  * but that also makes it fragile since it would be easy for someone to
688  * accidentally introduce an assumption of title validity to the code we
689  * are calling.
690  */
693 
694  return true;
695  }
696 }
697 
698 $maintClass = NamespaceDupes::class;
699 require_once RUN_MAINTENANCE_IF_MAIN;
LIST_OR
const LIST_OR
Definition: Defines.php:46
NamespaceDupes\getTargetList
getTargetList( $ns, $name, $options)
Find pages in main and talk namespaces that have a prefix of the new namespace so we know titles that...
Definition: namespaceDupes.php:497
NamespaceDupes\mergePage
mergePage( $row, Title $newTitle)
Merge page histories.
Definition: namespaceDupes.php:655
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:203
NamespaceDupes\$resolvableLinks
int $resolvableLinks
Total number of links that need fixing that are automatically resolveable.
Definition: namespaceDupes.php:65
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:329
LIST_AND
const LIST_AND
Definition: Defines.php:43
NamespaceDupes\__construct
__construct()
Default constructor.
Definition: namespaceDupes.php:80
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the pending update queue for execution at the appropriate time.
Definition: DeferredUpdates.php:125
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:63
Title\getArticleID
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:2860
NamespaceDupes
Maintenance script that checks for articles to fix after adding/deleting namespaces.
Definition: namespaceDupes.php:42
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:59
NamespaceDupes\$deletedLinks
int $deletedLinks
Total number of links deleted because they weren't automatically resolveable due to the target alread...
Definition: namespaceDupes.php:78
$res
$res
Definition: testCompression.php:57
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
NS_MAIN
const NS_MAIN
Definition: Defines.php:64
NamespaceDupes\checkAll
checkAll( $options)
Check all namespaces.
Definition: namespaceDupes.php:132
Maintenance\beginTransaction
beginTransaction(IDatabase $dbw, $fname)
Begin a transaction on a DB.
Definition: Maintenance.php:1406
MediaWiki\Linker\LinkTarget\getNamespace
getNamespace()
Get the namespace index.
NamespaceDupes\$resolvablePages
int $resolvablePages
Total number of pages that need fixing that are automatically resolveable.
Definition: namespaceDupes.php:53
NamespaceDupes\$db
IMaintainableDatabase $db
Definition: namespaceDupes.php:47
Maintenance\getConfig
getConfig()
Definition: Maintenance.php:598
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:26
NamespaceDupes\execute
execute()
Do the actual work.
Definition: namespaceDupes.php:101
NamespaceDupes\canMerge
canMerge( $id, LinkTarget $linkTarget, &$logStatus)
Determine if we can merge a page.
Definition: namespaceDupes.php:634
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:249
NamespaceDupes\getAlternateTitle
getAlternateTitle( $ns, $dbk, $options)
Get an alternative title to move a page to.
Definition: namespaceDupes.php:572
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:648
NamespaceDupes\checkNamespace
checkNamespace( $ns, $name, $options)
Check a given prefix and try to move it into the given destination namespace.
Definition: namespaceDupes.php:262
NamespaceDupes\movePage
movePage( $id, LinkTarget $newLinkTarget)
Move a page.
Definition: namespaceDupes.php:589
NS_TALK
const NS_TALK
Definition: Defines.php:65
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:674
MediaWiki\Deferred\LinksUpdate\LinksDeletionUpdate
Update object handling the cleanup of links tables after a page was deleted.
Definition: LinksDeletionUpdate.php:38
DB_PRIMARY
const DB_PRIMARY
Definition: defines.php:27
NamespaceDupes\getDestinationTitle
getDestinationTitle( $ns, $name, $sourceNs, $sourceDbk)
Get the preferred destination title for a given target page.
Definition: namespaceDupes.php:554
MediaWiki\Linker\LinkTarget\getDBkey
getDBkey()
Get the main part of the link target, in canonical database form.
Maintenance\commitTransaction
commitTransaction(IDatabase $dbw, $fname)
Commit the transaction on a DB handle and wait for replica DBs to catch up.
Definition: Maintenance.php:1421
Maintenance\getDB
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.
Definition: Maintenance.php:1375
DeferredUpdates\doUpdates
static doUpdates( $mode='run', $stage=self::ALL)
Consume and execute all pending updates.
Definition: DeferredUpdates.php:179
NamespaceDupes\checkLinkTable
checkLinkTable( $table, $fieldPrefix, $ns, $name, $options, $extraConds=[])
Check and repair the destination fields in a link table.
Definition: namespaceDupes.php:366
Title
Represents a title within MediaWiki.
Definition: Title.php:47
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:286
$maintClass
$maintClass
Definition: namespaceDupes.php:698
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:435
NamespaceDupes\getDestination
getDestination( $ns, $name, $sourceNs, $sourceDbk)
Get the preferred destination for a given target page.
Definition: namespaceDupes.php:531
NamespaceDupes\$totalLinks
int $totalLinks
Total number of erroneous links.
Definition: namespaceDupes.php:71
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular option was set.
Definition: Maintenance.php:271
NamespaceDupes\checkPrefix
checkPrefix( $options)
Move the given pseudo-namespace, either replacing the colon with a hyphen (useful for pseudo-namespac...
Definition: namespaceDupes.php:479
NamespaceDupes\getInterwikiList
getInterwikiList()
Definition: namespaceDupes.php:249
NamespaceDupes\$totalPages
int $totalPages
Total number of pages that need fixing.
Definition: namespaceDupes.php:59
Wikimedia\Rdbms\IMaintainableDatabase
Advanced database interface for IDatabase handles that include maintenance methods.
Definition: IMaintainableDatabase.php:38