MediaWiki master
namespaceDupes.php
Go to the documentation of this file.
1<?php
27require_once __DIR__ . '/Maintenance.php';
28
38
46
51 private $resolvablePages = 0;
52
57 private $totalPages = 0;
58
63 private $resolvableLinks = 0;
64
69 private $totalLinks = 0;
70
76 private $deletedLinks = 0;
77
78 public function __construct() {
79 parent::__construct();
80 $this->addDescription( 'Find and fix pages affected by namespace addition/removal' );
81 $this->addOption( 'fix', 'Attempt to automatically fix errors and delete broken links' );
82 $this->addOption( 'merge', "Instead of renaming conflicts, do a history merge with " .
83 "the correct title" );
84 $this->addOption( 'add-suffix', "Dupes will be renamed with correct namespace with " .
85 "<text> appended after the article name", false, true );
86 $this->addOption( 'add-prefix', "Dupes will be renamed with correct namespace with " .
87 "<text> prepended before the article name", false, true );
88 $this->addOption( 'source-pseudo-namespace', "Move all pages with the given source " .
89 "prefix (with an implied colon following it). If --dest-namespace is not specified, " .
90 "the colon will be replaced with a hyphen.",
91 false, true );
92 $this->addOption( 'dest-namespace', "In combination with --source-pseudo-namespace, " .
93 "specify the namespace ID of the destination.", false, true );
94 $this->addOption( 'move-talk', "If this is specified, pages in the Talk namespace that " .
95 "begin with a conflicting prefix will be renamed, for example " .
96 "Talk:File:Foo -> File_Talk:Foo" );
97 }
98
99 public function execute() {
100 $options = [
101 'fix' => $this->hasOption( 'fix' ),
102 'merge' => $this->hasOption( 'merge' ),
103 'add-suffix' => $this->getOption( 'add-suffix', '' ),
104 'add-prefix' => $this->getOption( 'add-prefix', '' ),
105 'move-talk' => $this->hasOption( 'move-talk' ),
106 'source-pseudo-namespace' => $this->getOption( 'source-pseudo-namespace', '' ),
107 'dest-namespace' => intval( $this->getOption( 'dest-namespace', 0 ) )
108 ];
109
110 if ( $options['source-pseudo-namespace'] !== '' ) {
111 $retval = $this->checkPrefix( $options );
112 } else {
113 $retval = $this->checkAll( $options );
114 }
115
116 if ( $retval ) {
117 $this->output( "\nLooks good!\n" );
118 } else {
119 $this->output( "\nOh noeees\n" );
120 }
121 }
122
130 private function checkAll( $options ) {
131 $contLang = $this->getServiceContainer()->getContentLanguage();
132 $spaces = [];
133
134 // List interwikis first, so they'll be overridden
135 // by any conflicting local namespaces.
136 foreach ( $this->getInterwikiList() as $prefix ) {
137 $name = $contLang->ucfirst( $prefix );
138 $spaces[$name] = 0;
139 }
140
141 // Now pull in all canonical and alias namespaces...
142 foreach (
143 $this->getServiceContainer()->getNamespaceInfo()->getCanonicalNamespaces()
144 as $ns => $name
145 ) {
146 // This includes $wgExtraNamespaces
147 if ( $name !== '' ) {
148 $spaces[$name] = $ns;
149 }
150 }
151 foreach ( $contLang->getNamespaces() as $ns => $name ) {
152 if ( $name !== '' ) {
153 $spaces[$name] = $ns;
154 }
155 }
156 foreach ( $contLang->getNamespaceAliases() as $name => $ns ) {
157 $spaces[$name] = $ns;
158 }
159
160 // We'll need to check for lowercase keys as well,
161 // since we're doing case-sensitive searches in the db.
162 $capitalLinks = $this->getConfig()->get( MainConfigNames::CapitalLinks );
163 foreach ( $spaces as $name => $ns ) {
164 $moreNames = [];
165 $moreNames[] = $contLang->uc( $name );
166 $moreNames[] = $contLang->ucfirst( $contLang->lc( $name ) );
167 $moreNames[] = $contLang->ucwords( $name );
168 $moreNames[] = $contLang->ucwords( $contLang->lc( $name ) );
169 $moreNames[] = $contLang->ucwordbreaks( $name );
170 $moreNames[] = $contLang->ucwordbreaks( $contLang->lc( $name ) );
171 if ( !$capitalLinks ) {
172 foreach ( $moreNames as $altName ) {
173 $moreNames[] = $contLang->lcfirst( $altName );
174 }
175 $moreNames[] = $contLang->lcfirst( $name );
176 }
177 foreach ( array_unique( $moreNames ) as $altName ) {
178 if ( $altName !== $name ) {
179 $spaces[$altName] = $ns;
180 }
181 }
182 }
183
184 // Sort by namespace index, and if there are two with the same index,
185 // break the tie by sorting by name
186 $origSpaces = $spaces;
187 uksort( $spaces, static function ( $a, $b ) use ( $origSpaces ) {
188 return $origSpaces[$a] <=> $origSpaces[$b]
189 ?: $a <=> $b;
190 } );
191
192 $ok = true;
193 foreach ( $spaces as $name => $ns ) {
194 $ok = $this->checkNamespace( $ns, $name, $options ) && $ok;
195 }
196
197 $this->output(
198 "{$this->totalPages} pages to fix, " .
199 "{$this->resolvablePages} were resolvable.\n\n"
200 );
201
202 foreach ( $spaces as $name => $ns ) {
203 if ( $ns != 0 ) {
204 /* Fix up link destinations for non-interwiki links only.
205 *
206 * For example if a page has [[Foo:Bar]] and then a Foo namespace
207 * is introduced, pagelinks needs to be updated to have
208 * page_namespace = NS_FOO.
209 *
210 * If instead an interwiki prefix was introduced called "Foo",
211 * the link should instead be moved to the iwlinks table. If a new
212 * language is introduced called "Foo", or if there is a pagelink
213 * [[fr:Bar]] when interlanguage magic links are turned on, the
214 * link would have to be moved to the langlinks table. Let's put
215 * those cases in the too-hard basket for now. The consequences are
216 * not especially severe.
217 * @fixme Handle interwiki links, and pagelinks to Category:, File:
218 * which probably need reparsing.
219 */
220
221 $this->checkLinkTable( 'pagelinks', 'pl', $ns, $name, $options );
222 $this->checkLinkTable( 'templatelinks', 'tl', $ns, $name, $options );
223
224 // The redirect table has interwiki links randomly mixed in, we
225 // need to filter those out. For example [[w:Foo:Bar]] would
226 // have rd_interwiki=w and rd_namespace=0, which would match the
227 // query for a conflicting namespace "Foo" if filtering wasn't done.
228 $this->checkLinkTable( 'redirect', 'rd', $ns, $name, $options,
229 [ 'rd_interwiki' => '' ] );
230 }
231 }
232
233 $this->output(
234 "{$this->totalLinks} links to fix, " .
235 "{$this->resolvableLinks} were resolvable, " .
236 "{$this->deletedLinks} were deleted.\n"
237 );
238
239 return $ok;
240 }
241
245 private function getInterwikiList() {
246 $result = $this->getServiceContainer()->getInterwikiLookup()->getAllPrefixes();
247 return array_column( $result, 'iw_prefix' );
248 }
249
258 private function checkNamespace( $ns, $name, $options ) {
259 $targets = $this->getTargetList( $ns, $name, $options );
260 $count = $targets->numRows();
261 $this->totalPages += $count;
262 if ( $count == 0 ) {
263 return true;
264 }
265
266 $dryRunNote = $options['fix'] ? '' : ' DRY RUN ONLY';
267
268 $ok = true;
269 foreach ( $targets as $row ) {
270 // Find the new title and determine the action to take
271
272 $newTitle = $this->getDestinationTitle(
273 $ns, $name, $row->page_namespace, $row->page_title );
274 $logStatus = false;
275 if ( !$newTitle ) {
276 if ( $options['add-prefix'] == '' && $options['add-suffix'] == '' ) {
277 $logStatus = 'invalid title and --add-prefix not specified';
278 $action = 'abort';
279 } else {
280 $action = 'alternate';
281 }
282 } elseif ( $newTitle->exists() ) {
283 if ( $options['merge'] ) {
284 if ( $this->canMerge( $row->page_id, $newTitle, $logStatus ) ) {
285 $action = 'merge';
286 } else {
287 $action = 'abort';
288 }
289 } elseif ( $options['add-prefix'] == '' && $options['add-suffix'] == '' ) {
290 $action = 'abort';
291 $logStatus = 'dest title exists and --add-prefix not specified';
292 } else {
293 $action = 'alternate';
294 }
295 } else {
296 $action = 'move';
297 $logStatus = 'no conflict';
298 }
299 if ( $action === 'alternate' ) {
300 [ $ns, $dbk ] = $this->getDestination( $ns, $name, $row->page_namespace,
301 $row->page_title );
302 $newTitle = $this->getAlternateTitle( $ns, $dbk, $options );
303 if ( !$newTitle ) {
304 $action = 'abort';
305 $logStatus = 'alternate title is invalid';
306 } elseif ( $newTitle->exists() ) {
307 $action = 'abort';
308 $logStatus = 'alternate title conflicts';
309 } else {
310 $action = 'move';
311 $logStatus = 'alternate';
312 }
313 }
314
315 // Take the action or log a dry run message
316
317 $logTitle = "id={$row->page_id} ns={$row->page_namespace} dbk={$row->page_title}";
318 $pageOK = true;
319
320 switch ( $action ) {
321 case 'abort':
322 $this->output( "$logTitle *** $logStatus\n" );
323 $pageOK = false;
324 break;
325 case 'move':
326 $this->output( "$logTitle -> " .
327 $newTitle->getPrefixedDBkey() . " ($logStatus)$dryRunNote\n" );
328
329 if ( $options['fix'] ) {
330 $pageOK = $this->movePage( $row->page_id, $newTitle );
331 }
332 break;
333 case 'merge':
334 $this->output( "$logTitle => " .
335 $newTitle->getPrefixedDBkey() . " (merge)$dryRunNote\n" );
336
337 if ( $options['fix'] ) {
338 $pageOK = $this->mergePage( $row, $newTitle );
339 }
340 break;
341 }
342
343 if ( $pageOK ) {
344 $this->resolvablePages++;
345 } else {
346 $ok = false;
347 }
348 }
349
350 return $ok;
351 }
352
362 private function checkLinkTable( $table, $fieldPrefix, $ns, $name, $options,
363 $extraConds = []
364 ) {
365 $dbw = $this->getPrimaryDB();
366
367 $batchConds = [];
368 $fromField = "{$fieldPrefix}_from";
369 $batchSize = 100;
370 $sqb = $dbw->newSelectQueryBuilder()
371 ->select( $fromField )
372 ->where( $extraConds )
373 ->limit( $batchSize );
374
375 $linksMigration = $this->getServiceContainer()->getLinksMigration();
376 if ( isset( $linksMigration::$mapping[$table] ) ) {
377 $sqb->queryInfo( $linksMigration->getQueryInfo( $table ) );
378 [ $namespaceField, $titleField ] = $linksMigration->getTitleFields( $table );
379 $schemaMigrationStage = $linksMigration::$mapping[$table]['config'] === -1
381 : $this->getConfig()->get( $linksMigration::$mapping[$table]['config'] );
382 $linkTargetLookup = $this->getServiceContainer()->getLinkTargetLookup();
383 $targetIdField = $linksMigration::$mapping[$table]['target_id'];
384 } else {
385 $sqb->table( $table );
386 $namespaceField = "{$fieldPrefix}_namespace";
387 $titleField = "{$fieldPrefix}_title";
388 $sqb->fields( [ $namespaceField, $titleField ] );
389 // Variables only used for links migration, init only
390 $schemaMigrationStage = -1;
391 $linkTargetLookup = null;
392 $targetIdField = '';
393 }
394 $sqb->andWhere( [
395 $namespaceField => 0,
396 $dbw->expr( $titleField, IExpression::LIKE, new LikeValue( "$name:", $dbw->anyString() ) ),
397 ] )
398 ->orderBy( [ $titleField, $fromField ] )
399 ->caller( __METHOD__ );
400
401 $updateRowsPerQuery = $this->getConfig()->get( MainConfigNames::UpdateRowsPerQuery );
402 while ( true ) {
403 $res = ( clone $sqb )
404 ->andWhere( $batchConds )
405 ->fetchResultSet();
406 if ( $res->numRows() == 0 ) {
407 break;
408 }
409
410 $rowsToDeleteIfStillExists = [];
411
412 foreach ( $res as $row ) {
413 $logTitle = "from={$row->$fromField} ns={$row->$namespaceField} " .
414 "dbk={$row->$titleField}";
415 $destTitle = $this->getDestinationTitle(
416 $ns, $name, $row->$namespaceField, $row->$titleField );
417 $this->totalLinks++;
418 if ( !$destTitle ) {
419 $this->output( "$table $logTitle *** INVALID\n" );
420 continue;
421 }
422 $this->resolvableLinks++;
423 if ( !$options['fix'] ) {
424 $this->output( "$table $logTitle -> " .
425 $destTitle->getPrefixedDBkey() . " DRY RUN\n" );
426 continue;
427 }
428
429 if ( isset( $linksMigration::$mapping[$table] ) ) {
430 $setValue = [];
431 if ( $schemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) {
432 $setValue[$targetIdField] = $linkTargetLookup->acquireLinkTargetId( $destTitle, $dbw );
433 }
434 if ( $schemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) {
435 $setValue["{$fieldPrefix}_namespace"] = $destTitle->getNamespace();
436 $setValue["{$fieldPrefix}_title"] = $destTitle->getDBkey();
437 }
438 $whereCondition = $linksMigration->getLinksConditions(
439 $table,
440 new TitleValue( 0, $row->$titleField )
441 );
442 $deleteCondition = $linksMigration->getLinksConditions(
443 $table,
444 new TitleValue( (int)$row->$namespaceField, $row->$titleField )
445 );
446 } else {
447 $setValue = [
448 $namespaceField => $destTitle->getNamespace(),
449 $titleField => $destTitle->getDBkey()
450 ];
451 $whereCondition = [
452 $namespaceField => 0,
453 $titleField => $row->$titleField
454 ];
455 $deleteCondition = [
456 $namespaceField => $row->$namespaceField,
457 $titleField => $row->$titleField,
458 ];
459 }
460
461 $dbw->newUpdateQueryBuilder()
462 ->update( $table )
463 ->ignore()
464 ->set( $setValue )
465 ->where( [ $fromField => $row->$fromField ] )
466 ->andWhere( $whereCondition )
467 ->caller( __METHOD__ )
468 ->execute();
469
470 // In case there is a key conflict on UPDATE IGNORE the row needs deletion
471 $rowsToDeleteIfStillExists[] = array_merge( [ $fromField => $row->$fromField ], $deleteCondition );
472
473 $this->output( "$table $logTitle -> " .
474 $destTitle->getPrefixedDBkey() . "\n"
475 );
476 }
477
478 if ( $options['fix'] && count( $rowsToDeleteIfStillExists ) > 0 ) {
479 $affectedRows = 0;
480 $deleteBatches = array_chunk( $rowsToDeleteIfStillExists, $updateRowsPerQuery );
481 foreach ( $deleteBatches as $deleteBatch ) {
482 $dbw->newDeleteQueryBuilder()
483 ->deleteFrom( $table )
484 ->where( $dbw->factorConds( $deleteBatch ) )
485 ->caller( __METHOD__ )
486 ->execute();
487 $affectedRows += $dbw->affectedRows();
488 if ( count( $deleteBatches ) > 1 ) {
489 $this->waitForReplication();
490 }
491 }
492
493 $this->deletedLinks += $affectedRows;
494 $this->resolvableLinks -= $affectedRows;
495 }
496
497 $batchConds = [
498 $dbw->buildComparison( '>', [
499 // @phan-suppress-next-line PhanPossiblyUndeclaredVariable rows contains at least one item
500 $titleField => $row->$titleField,
501 // @phan-suppress-next-line PhanPossiblyUndeclaredVariable rows contains at least one item
502 $fromField => $row->$fromField,
503 ] )
504 ];
505
506 $this->waitForReplication();
507 }
508 }
509
517 private function checkPrefix( $options ) {
518 $prefix = $options['source-pseudo-namespace'];
519 $ns = $options['dest-namespace'];
520 $this->output( "Checking prefix \"$prefix\" vs namespace $ns\n" );
521
522 return $this->checkNamespace( $ns, $prefix, $options );
523 }
524
535 private function getTargetList( $ns, $name, $options ) {
536 $dbw = $this->getPrimaryDB();
537
538 if (
539 $options['move-talk'] &&
540 $this->getServiceContainer()->getNamespaceInfo()->isSubject( $ns )
541 ) {
542 $checkNamespaces = [ NS_MAIN, NS_TALK ];
543 } else {
544 $checkNamespaces = NS_MAIN;
545 }
546
547 return $dbw->newSelectQueryBuilder()
548 ->select( [ 'page_id', 'page_title', 'page_namespace' ] )
549 ->from( 'page' )
550 ->where( [
551 'page_namespace' => $checkNamespaces,
552 $dbw->expr( 'page_title', IExpression::LIKE, new LikeValue( "$name:", $dbw->anyString() ) ),
553 ] )
554 ->caller( __METHOD__ )->fetchResultSet();
555 }
556
565 private function getDestination( $ns, $name, $sourceNs, $sourceDbk ) {
566 $dbk = substr( $sourceDbk, strlen( "$name:" ) );
567 if ( $ns <= 0 ) {
568 // An interwiki or an illegal namespace like "Special" or "Media"
569 // try an alternate encoding with '-' for ':'
570 $dbk = "$name-" . $dbk;
571 $ns = 0;
572 }
573 $destNS = $ns;
574 $nsInfo = $this->getServiceContainer()->getNamespaceInfo();
575 if ( $sourceNs == NS_TALK && $nsInfo->isSubject( $ns ) ) {
576 // This is an associated talk page moved with the --move-talk feature.
577 $destNS = $nsInfo->getTalk( $destNS );
578 }
579 return [ $destNS, $dbk ];
580 }
581
590 private function getDestinationTitle( $ns, $name, $sourceNs, $sourceDbk ) {
591 [ $destNS, $dbk ] = $this->getDestination( $ns, $name, $sourceNs, $sourceDbk );
592 $newTitle = Title::makeTitleSafe( $destNS, $dbk );
593 if ( !$newTitle || !$newTitle->canExist() ) {
594 return false;
595 }
596 return $newTitle;
597 }
598
608 private function getAlternateTitle( $ns, $dbk, $options ) {
609 $prefix = $options['add-prefix'];
610 $suffix = $options['add-suffix'];
611 if ( $prefix == '' && $suffix == '' ) {
612 return false;
613 }
614 $newDbk = $prefix . $dbk . $suffix;
615 return Title::makeTitleSafe( $ns, $newDbk );
616 }
617
625 private function movePage( $id, LinkTarget $newLinkTarget ) {
626 $dbw = $this->getPrimaryDB();
627
628 $dbw->newUpdateQueryBuilder()
629 ->update( 'page' )
630 ->set( [
631 "page_namespace" => $newLinkTarget->getNamespace(),
632 "page_title" => $newLinkTarget->getDBkey(),
633 ] )
634 ->where( [
635 "page_id" => $id,
636 ] )
637 ->caller( __METHOD__ )
638 ->execute();
639
640 // Update *_from_namespace in links tables
641 $fromNamespaceTables = [
642 [ 'templatelinks', 'tl', [ 'tl_target_id' ] ],
643 [ 'imagelinks', 'il', [ 'il_to' ] ]
644 ];
645 if ( $this->getConfig()->get( MainConfigNames::PageLinksSchemaMigrationStage ) & SCHEMA_COMPAT_WRITE_OLD ) {
646 $fromNamespaceTables[] = [ 'pagelinks', 'pl', [ 'pl_namespace', 'pl_title' ] ];
647 } else {
648 $fromNamespaceTables[] = [ 'pagelinks', 'pl', [ 'pl_target_id' ] ];
649 }
650 $updateRowsPerQuery = $this->getConfig()->get( MainConfigNames::UpdateRowsPerQuery );
651 foreach ( $fromNamespaceTables as [ $table, $fieldPrefix, $additionalPrimaryKeyFields ] ) {
652 $fromField = "{$fieldPrefix}_from";
653 $fromNamespaceField = "{$fieldPrefix}_from_namespace";
654
655 $res = $dbw->newSelectQueryBuilder()
656 ->select( $additionalPrimaryKeyFields )
657 ->from( $table )
658 ->where( [ $fromField => $id ] )
659 ->andWhere( $dbw->expr( $fromNamespaceField, '!=', $newLinkTarget->getNamespace() ) )
660 ->caller( __METHOD__ )
661 ->fetchResultSet();
662 if ( !$res ) {
663 continue;
664 }
665
666 $updateConds = [];
667 foreach ( $res as $row ) {
668 $updateConds[] = array_merge( [ $fromField => $id ], (array)$row );
669 }
670 $updateBatches = array_chunk( $updateConds, $updateRowsPerQuery );
671 foreach ( $updateBatches as $updateBatch ) {
672 $dbw->newUpdateQueryBuilder()
673 ->update( $table )
674 ->set( [ $fromNamespaceField => $newLinkTarget->getNamespace() ] )
675 ->where( $dbw->factorConds( $updateBatch ) )
676 ->caller( __METHOD__ )
677 ->execute();
678 if ( count( $updateBatches ) > 1 ) {
679 $this->waitForReplication();
680 }
681 }
682 }
683
684 return true;
685 }
686
699 private function canMerge( $id, LinkTarget $linkTarget, &$logStatus ) {
700 $revisionLookup = $this->getServiceContainer()->getRevisionLookup();
701 $latestDest = $revisionLookup->getRevisionByTitle( $linkTarget, 0,
702 IDBAccessObject::READ_LATEST );
703 $latestSource = $revisionLookup->getRevisionByPageId( $id, 0,
704 IDBAccessObject::READ_LATEST );
705 if ( $latestSource->getTimestamp() > $latestDest->getTimestamp() ) {
706 $logStatus = 'cannot merge since source is later';
707 return false;
708 } else {
709 return true;
710 }
711 }
712
720 private function mergePage( $row, Title $newTitle ) {
721 $dbw = $this->getPrimaryDB();
722 $updateRowsPerQuery = $this->getConfig()->get( MainConfigNames::UpdateRowsPerQuery );
723
724 $id = $row->page_id;
725
726 // Construct the WikiPage object we will need later, while the
727 // page_id still exists. Note that this cannot use makeTitleSafe(),
728 // we are deliberately constructing an invalid title.
729 $sourceTitle = Title::makeTitle( $row->page_namespace, $row->page_title );
730 $sourceTitle->resetArticleID( $id );
731 $wikiPage = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $sourceTitle );
732 $wikiPage->loadPageData( IDBAccessObject::READ_LATEST );
733
734 $destId = $newTitle->getArticleID();
735 $this->beginTransaction( $dbw, __METHOD__ );
736 $revIds = $dbw->newSelectQueryBuilder()
737 ->select( 'rev_id' )
738 ->from( 'revision' )
739 ->where( [ 'rev_page' => $id ] )
740 ->caller( __METHOD__ )
741 ->fetchFieldValues();
742 $updateBatches = array_chunk( array_map( 'intval', $revIds ), $updateRowsPerQuery );
743 foreach ( $updateBatches as $updateBatch ) {
744 $dbw->newUpdateQueryBuilder()
745 ->update( 'revision' )
746 ->set( [ 'rev_page' => $destId ] )
747 ->where( [ 'rev_id' => $updateBatch ] )
748 ->caller( __METHOD__ )
749 ->execute();
750 if ( count( $updateBatches ) > 1 ) {
751 $this->waitForReplication();
752 }
753 }
754
755 $dbw->newDeleteQueryBuilder()
756 ->deleteFrom( 'page' )
757 ->where( [ 'page_id' => $id ] )
758 ->caller( __METHOD__ )
759 ->execute();
760
761 $this->commitTransaction( $dbw, __METHOD__ );
762
763 /* Call LinksDeletionUpdate to delete outgoing links from the old title,
764 * and update category counts.
765 *
766 * Calling external code with a fake broken Title is a fairly dubious
767 * idea. It's necessary because it's quite a lot of code to duplicate,
768 * but that also makes it fragile since it would be easy for someone to
769 * accidentally introduce an assumption of title validity to the code we
770 * are calling.
771 */
772 DeferredUpdates::addUpdate( new LinksDeletionUpdate( $wikiPage ) );
773 DeferredUpdates::doUpdates();
774
775 return true;
776 }
777}
778
779$maintClass = NamespaceDupes::class;
780require_once RUN_MAINTENANCE_IF_MAIN;
const SCHEMA_COMPAT_WRITE_OLD
Definition Defines.php:276
const NS_MAIN
Definition Defines.php:65
const MIGRATION_NEW
Definition Defines.php:317
const SCHEMA_COMPAT_WRITE_NEW
Definition Defines.php:280
const NS_TALK
Definition Defines.php:66
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
beginTransaction(IDatabase $dbw, $fname)
Begin a transaction on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transaction on a DB handle and wait for replica DBs to catch up.
output( $out, $channel=null)
Throw some output to the user.
waitForReplication()
Wait for replica DBs to catch up.
hasOption( $name)
Checks to see if a particular option was set.
getServiceContainer()
Returns the main service container.
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.
Defer callable updates to run later in the PHP process.
Update object handling the cleanup of links tables after a page was deleted.
A class containing constants representing the names of configuration variables.
Represents the target of a wiki link.
Represents a title within MediaWiki.
Definition Title.php:79
canExist()
Can this title represent a page in the wiki's database?
Definition Title.php:1213
exists( $flags=0)
Check if page exists.
Definition Title.php:3150
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition Title.php:2595
getPrefixedDBkey()
Get the prefixed database key form.
Definition Title.php:1850
Maintenance script that checks for articles to fix after adding/deleting namespaces.
execute()
Do the actual work.
__construct()
Default constructor.
Content of like value.
Definition LikeValue.php:14
Represents the target of a wiki link.
getNamespace()
Get the namespace index.
getDBkey()
Get the main part of the link target, in canonical database form.
Result wrapper for grabbing data queried from an IDatabase object.
$maintClass