MediaWiki REL1_37
uppercaseTitlesForUnicodeTransition.php
Go to the documentation of this file.
1<?php
27
28require_once __DIR__ . '/Maintenance.php';
29
37
38 private const MOVE = 0;
39 private const INPLACE_MOVE = 1;
40 private const UPPERCASE = 2;
41
43 private $run = false;
44
46 private $charmap = [];
47
49 private $user;
50
52 private $reason = 'Uppercasing title for Unicode upgrade';
53
55 private $tags = [];
56
58 private $seenUsers = [];
59
61 private $namespaces = null;
62
64 private $prefix = null, $suffix = null;
65
67 private $prefixNs = null;
68
70 private $tables = null;
71
72 public function __construct() {
73 parent::__construct();
74 $this->addDescription(
75 "Rename titles when changing behavior of Language::ucfirst().\n"
76 . "\n"
77 . "This script skips User and User_talk pages for registered users, as renaming of users "
78 . "is too complex to try to implement here. Use something like Extension:Renameuser to "
79 . "clean those up; this script can provide a list of user names affected."
80 );
81 $this->addOption(
82 'charmap', 'Character map generated by maintenance/language/generateUcfirstOverrides.php',
83 true, true
84 );
85 $this->addOption(
86 'user', 'System user to use to do the renames. Default is "Maintenance script".', false, true
87 );
88 $this->addOption(
89 'steal',
90 'If the username specified by --user exists, specify this to force conversion to a system user.'
91 );
92 $this->addOption(
93 'run', 'If not specified, the script will not actually perform any moves (i.e. it will dry-run).'
94 );
95 $this->addOption(
96 'prefix', 'When the new title already exists, add this prefix.', false, true
97 );
98 $this->addOption(
99 'suffix', 'When the new title already exists, add this suffix.', false, true
100 );
101 $this->addOption( 'reason', 'Reason to use when moving pages.', false, true );
102 $this->addOption( 'tag', 'Change tag to apply when moving pages.', false, true );
103 $this->addOption( 'tables', 'Comma-separated list of database tables to process.', false, true );
104 $this->addOption(
105 'userlist', 'Filename to which to output usernames needing rename.', false, true
106 );
107 $this->setBatchSize( 1000 );
108 }
109
110 public function execute() {
111 $this->run = $this->getOption( 'run', false );
112
113 if ( $this->run ) {
114 $username = $this->getOption( 'user', User::MAINTENANCE_SCRIPT_USER );
115 $steal = $this->getOption( 'steal', false );
116 $this->user = User::newSystemUser( $username, [ 'steal' => $steal ] );
117 if ( !$this->user ) {
118 $user = User::newFromName( $username );
119 if ( !$steal && $user && $user->isRegistered() ) {
120 $this->fatalError( "User $username already exists.\n"
121 . "Use --steal if you really want to steal it from the human who currently owns it."
122 );
123 }
124 $this->fatalError( "Could not obtain system user $username." );
125 }
126 }
127
128 $tables = $this->getOption( 'tables' );
129 if ( $tables !== null ) {
130 $this->tables = explode( ',', $tables );
131 }
132
133 $prefix = $this->getOption( 'prefix' );
134 if ( $prefix !== null ) {
135 $title = Title::newFromText( $prefix . 'X' );
136 if ( !$title || substr( $title->getDBkey(), -1 ) !== 'X' ) {
137 $this->fatalError( 'Invalid --prefix.' );
138 }
139 if ( $title->getNamespace() <= NS_MAIN || $title->isExternal() ) {
140 $this->fatalError( 'Invalid --prefix. It must not be in namespace 0 and must not be external' );
141 }
142 $this->prefixNs = $title->getNamespace();
143 $this->prefix = substr( $title->getText(), 0, -1 );
144 }
145 $this->suffix = $this->getOption( 'suffix' );
146
147 $this->reason = $this->getOption( 'reason' ) ?: $this->reason;
148 $this->tags = (array)$this->getOption( 'tag', null );
149
150 $charmapFile = $this->getOption( 'charmap' );
151 if ( !file_exists( $charmapFile ) ) {
152 $this->fatalError( "Charmap file $charmapFile does not exist." );
153 }
154 if ( !is_file( $charmapFile ) || !is_readable( $charmapFile ) ) {
155 $this->fatalError( "Charmap file $charmapFile is not readable." );
156 }
157 $this->charmap = require $charmapFile;
158 if ( !is_array( $this->charmap ) ) {
159 $this->fatalError( "Charmap file $charmapFile did not return a PHP array." );
160 }
161 $this->charmap = array_filter(
162 $this->charmap,
163 function ( $v, $k ) {
164 if ( mb_strlen( $k ) !== 1 ) {
165 $this->error( "Ignoring mapping from multi-character key '$k' to '$v'" );
166 return false;
167 }
168 return $k !== $v;
169 },
170 ARRAY_FILTER_USE_BOTH
171 );
172 if ( !$this->charmap ) {
173 $this->fatalError( "Charmap file $charmapFile did not contain any usable character mappings." );
174 }
175
176 $db = $this->getDB( $this->run ? DB_PRIMARY : DB_REPLICA );
177
178 // Process inplace moves first, before actual moves, so mungeTitle() doesn't get confused
179 $this->processTable(
180 $db, self::INPLACE_MOVE, 'archive', 'ar_namespace', 'ar_title', [ 'ar_timestamp', 'ar_id' ]
181 );
182 $this->processTable(
183 $db, self::INPLACE_MOVE, 'filearchive', NS_FILE, 'fa_name', [ 'fa_timestamp', 'fa_id' ]
184 );
185 $this->processTable(
186 $db, self::INPLACE_MOVE, 'logging', 'log_namespace', 'log_title', [ 'log_id' ]
187 );
188 $this->processTable(
189 $db, self::INPLACE_MOVE, 'protected_titles', 'pt_namespace', 'pt_title', []
190 );
191 $this->processTable( $db, self::MOVE, 'page', 'page_namespace', 'page_title', [ 'page_id' ] );
192 $this->processTable( $db, self::MOVE, 'image', NS_FILE, 'img_name', [] );
193 $this->processTable(
194 $db, self::UPPERCASE, 'redirect', 'rd_namespace', 'rd_title', [ 'rd_from' ]
195 );
196 $this->processUsers( $db );
197 }
198
206 private function getLikeBatches( IDatabase $db, $field, $batchSize = 100 ) {
207 $ret = [];
208 $likes = [];
209 foreach ( $this->charmap as $from => $to ) {
210 $likes[] = $field . $db->buildLike( $from, $db->anyString() );
211 if ( count( $likes ) >= $batchSize ) {
212 $ret[] = $db->makeList( $likes, $db::LIST_OR );
213 $likes = [];
214 }
215 }
216 if ( $likes ) {
217 $ret[] = $db->makeList( $likes, $db::LIST_OR );
218 }
219 return $ret;
220 }
221
230 private function getNamespaces() {
231 if ( $this->namespaces === null ) {
232 $nsinfo = MediaWikiServices::getInstance()->getNamespaceInfo();
233 $this->namespaces = array_filter(
234 array_keys( $nsinfo->getCanonicalNamespaces() ),
235 static function ( $ns ) use ( $nsinfo ) {
236 return $nsinfo->isMovable( $ns ) && $nsinfo->isCapitalized( $ns );
237 }
238 );
239 usort( $this->namespaces, static function ( $ns1, $ns2 ) use ( $nsinfo ) {
240 if ( $ns1 === $ns2 ) {
241 return 0;
242 }
243
244 $s1 = $nsinfo->getSubject( $ns1 );
245 $s2 = $nsinfo->getSubject( $ns2 );
246
247 // Order by subject namespace number first
248 if ( $s1 !== $s2 ) {
249 return $s1 < $s2 ? -1 : 1;
250 }
251
252 // Second, put subject namespaces before non-subject namespaces
253 if ( $s1 === $ns1 ) {
254 return -1;
255 }
256 if ( $s2 === $ns2 ) {
257 return 1;
258 }
259
260 // Don't care about the relative order if there are somehow
261 // multiple non-subject namespaces for a namespace.
262 return 0;
263 } );
264 }
265
266 return $this->namespaces;
267 }
268
276 private function isUserPage( IDatabase $db, $ns, $title ) {
277 if ( $ns !== NS_USER && $ns !== NS_USER_TALK ) {
278 return false;
279 }
280
281 list( $base ) = explode( '/', $title, 2 );
282 if ( !isset( $this->seenUsers[$base] ) ) {
283 // Can't use User directly because it might uppercase the name
284 $this->seenUsers[$base] = (bool)$db->selectField(
285 'user',
286 'user_id',
287 [ 'user_name' => strtr( $base, '_', ' ' ) ],
288 __METHOD__
289 );
290 }
291 return $this->seenUsers[$base];
292 }
293
301 private function mungeTitle( IDatabase $db, Title $oldTitle, Title &$newTitle ) {
302 $nt = $newTitle->getPrefixedText();
303
304 $munge = false;
305 if ( $this->isUserPage( $db, $newTitle->getNamespace(), $newTitle->getText() ) ) {
306 $munge = 'Target title\'s user exists';
307 } else {
308 $mpFactory = MediaWikiServices::getInstance()->getMovePageFactory();
309 $status = $mpFactory->newMovePage( $oldTitle, $newTitle )->isValidMove();
310 if ( !$status->isOK() && (
311 $status->hasMessage( 'articleexists' ) || $status->hasMessage( 'redirectexists' ) ) ) {
312 $munge = 'Target title exists';
313 }
314 }
315 if ( !$munge ) {
316 return true;
317 }
318
319 if ( $this->prefix !== null ) {
320 $newTitle = Title::makeTitle(
321 $this->prefixNs,
322 $this->prefix . $oldTitle->getPrefixedText() . ( $this->suffix ?? '' )
323 );
324 } elseif ( $this->suffix !== null ) {
325 $dbkey = $newTitle->getText();
326 $i = $newTitle->getNamespace() === NS_FILE ? strrpos( $dbkey, '.' ) : false;
327 if ( $i !== false ) {
328 $newTitle = Title::makeTitle(
329 $newTitle->getNamespace(),
330 substr( $dbkey, 0, $i ) . $this->suffix . substr( $dbkey, $i )
331 );
332 } else {
333 $newTitle = Title::makeTitle( $newTitle->getNamespace(), $dbkey . $this->suffix );
334 }
335 } else {
336 $this->error(
337 "Cannot move {$oldTitle->getPrefixedText()} → $nt: "
338 . "$munge and no --prefix or --suffix was given"
339 );
340 return false;
341 }
342
343 if ( !$newTitle->canExist() ) {
344 $this->error(
345 "Cannot move {$oldTitle->getPrefixedText()} → $nt: "
346 . "$munge and munged title '{$newTitle->getPrefixedText()}' is not valid"
347 );
348 return false;
349 }
350 if ( $newTitle->exists() ) {
351 $this->error(
352 "Cannot move {$oldTitle->getPrefixedText()} → $nt: "
353 . "$munge and munged title '{$newTitle->getPrefixedText()}' also exists"
354 );
355 return false;
356 }
357
358 return true;
359 }
360
368 private function doMove( IDatabase $db, $ns, $title ) {
369 $char = mb_substr( $title, 0, 1 );
370 if ( !array_key_exists( $char, $this->charmap ) ) {
371 $this->error(
372 "Query returned NS$ns $title, which does not begin with a character in the charmap."
373 );
374 return false;
375 }
376
377 if ( $this->isUserPage( $db, $ns, $title ) ) {
378 $this->output( "... Skipping user page NS$ns $title\n" );
379 return null;
380 }
381
382 $oldTitle = Title::makeTitle( $ns, $title );
383 $newTitle = Title::makeTitle( $ns, $this->charmap[$char] . mb_substr( $title, 1 ) );
384 $deletionReason = $this->shouldDelete( $db, $oldTitle, $newTitle );
385 if ( !$this->mungeTitle( $db, $oldTitle, $newTitle ) ) {
386 return false;
387 }
388
389 $services = MediaWikiServices::getInstance();
390 $mpFactory = $services->getMovePageFactory();
391 $movePage = $mpFactory->newMovePage( $oldTitle, $newTitle );
392 $status = $movePage->isValidMove();
393 if ( !$status->isOK() ) {
394 $this->error(
395 "Invalid move {$oldTitle->getPrefixedText()} → {$newTitle->getPrefixedText()}: "
396 . $status->getMessage( false, false, 'en' )->useDatabase( false )->plain()
397 );
398 return false;
399 }
400
401 if ( !$this->run ) {
402 $this->output(
403 "Would rename {$oldTitle->getPrefixedText()} → {$newTitle->getPrefixedText()}\n"
404 );
405 if ( $deletionReason ) {
406 $this->output(
407 "Would then delete {$newTitle->getPrefixedText()}: $deletionReason\n"
408 );
409 }
410 return true;
411 }
412
413 $status = $movePage->move( $this->user, $this->reason, false, $this->tags );
414 if ( !$status->isOK() ) {
415 $this->error(
416 "Move {$oldTitle->getPrefixedText()} → {$newTitle->getPrefixedText()} failed: "
417 . $status->getMessage( false, false, 'en' )->useDatabase( false )->plain()
418 );
419 }
420 $this->output( "Renamed {$oldTitle->getPrefixedText()} → {$newTitle->getPrefixedText()}\n" );
421
422 // The move created a log entry under the old invalid title. Fix it.
423 $db->update(
424 'logging',
425 [
426 'log_title' => $this->charmap[$char] . mb_substr( $title, 1 ),
427 ],
428 [
429 'log_namespace' => $oldTitle->getNamespace(),
430 'log_title' => $oldTitle->getDBkey(),
431 'log_page' => $newTitle->getArticleID(),
432 ],
433 __METHOD__
434 );
435
436 if ( $deletionReason !== null ) {
437 $page = $services->getWikiPageFactory()->newFromTitle( $newTitle );
438 $error = '';
439 $status = $page->doDeleteArticleReal(
440 $deletionReason,
441 $this->user,
442 false, // don't suppress
443 null, // unused
444 $error,
445 null, // unused
446 [], // tags
447 'delete',
448 true // immediate
449 );
450 if ( !$status->isOK() ) {
451 $this->error(
452 "Deletion of {$newTitle->getPrefixedText()} failed: "
453 . $status->getMessage( false, false, 'en' )->useDatabase( false )->plain()
454 );
455 return false;
456 }
457 $this->output( "Deleted {$newTitle->getPrefixedText()}\n" );
458 }
459
460 return true;
461 }
462
477 private function shouldDelete( IDatabase $db, Title $oldTitle, Title $newTitle ) {
478 $oldRow = $db->selectRow(
479 [ 'page', 'redirect' ],
480 [ 'ns' => 'rd_namespace', 'title' => 'rd_title' ],
481 [ 'page_namespace' => $oldTitle->getNamespace(), 'page_title' => $oldTitle->getDBkey() ],
482 __METHOD__,
483 [],
484 [ 'redirect' => [ 'JOIN', 'rd_from = page_id' ] ]
485 );
486 if ( !$oldRow ) {
487 // Not a redirect
488 return null;
489 }
490
491 if ( (int)$oldRow->ns === $newTitle->getNamespace() &&
492 $oldRow->title === $newTitle->getDBkey()
493 ) {
494 return $this->reason . ", and found that [[{$oldTitle->getPrefixedText()}]] is "
495 . "already a redirect to [[{$newTitle->getPrefixedText()}]]";
496 } else {
497 $newRow = $db->selectRow(
498 [ 'page', 'redirect' ],
499 [ 'ns' => 'rd_namespace', 'title' => 'rd_title' ],
500 [ 'page_namespace' => $newTitle->getNamespace(), 'page_title' => $newTitle->getDBkey() ],
501 __METHOD__,
502 [],
503 [ 'redirect' => [ 'JOIN', 'rd_from = page_id' ] ]
504 );
505 if ( $newRow && $oldRow->ns === $newRow->ns && $oldRow->title === $newRow->title ) {
506 $nt = Title::makeTitle( $newRow->ns, $newRow->title );
507 return $this->reason . ", and found that [[{$oldTitle->getPrefixedText()}]] and "
508 . "[[{$newTitle->getPrefixedText()}]] both redirect to [[{$nt->getPrefixedText()}]].";
509 }
510 }
511
512 return null;
513 }
514
527 private function doUpdate( IDatabase $db, $op, $table, $nsField, $titleField, $row ) {
528 $ns = is_int( $nsField ) ? $nsField : (int)$row->$nsField;
529 $title = $row->$titleField;
530
531 $char = mb_substr( $title, 0, 1 );
532 if ( !array_key_exists( $char, $this->charmap ) ) {
533 $r = json_encode( $row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
534 $this->error(
535 "Query returned $r, but title does not begin with a character in the charmap."
536 );
537 return false;
538 }
539
540 $oldTitle = Title::makeTitle( $ns, $title );
541 $newTitle = Title::makeTitle( $ns, $this->charmap[$char] . mb_substr( $title, 1 ) );
542 if ( $op !== self::UPPERCASE && !$this->mungeTitle( $db, $oldTitle, $newTitle ) ) {
543 return false;
544 }
545
546 if ( $this->run ) {
547 $db->update(
548 $table,
549 array_merge(
550 is_int( $nsField ) ? [] : [ $nsField => $newTitle->getNamespace() ],
551 [ $titleField => $newTitle->getDBkey() ]
552 ),
553 (array)$row,
554 __METHOD__
555 );
556 $r = json_encode( $row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
557 $this->output( "Set $r to {$newTitle->getPrefixedText()}\n" );
558 } else {
559 $r = json_encode( $row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
560 $this->output( "Would set $r to {$newTitle->getPrefixedText()}\n" );
561 }
562
563 return true;
564 }
565
579 private function processTable( IDatabase $db, $op, $table, $nsField, $titleField, $pkFields ) {
580 if ( $this->tables !== null && !in_array( $table, $this->tables, true ) ) {
581 $this->output( "Skipping table `$table`, not in --tables.\n" );
582 return;
583 }
584
585 $batchSize = $this->getBatchSize();
586 $namespaces = $this->getNamespaces();
587 $likes = $this->getLikeBatches( $db, $titleField );
588 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
589
590 if ( is_int( $nsField ) ) {
591 $namespaces = array_intersect( $namespaces, [ $nsField ] );
592 }
593
594 if ( !$namespaces ) {
595 $this->output( "Skipping table `$table`, no valid namespaces.\n" );
596 return;
597 }
598
599 $this->output( "Processing table `$table`...\n" );
600
601 $selectFields = array_merge(
602 is_int( $nsField ) ? [] : [ $nsField ],
603 [ $titleField ],
604 $pkFields
605 );
606 $contFields = array_reverse( array_merge( [ $titleField ], $pkFields ) );
607
609 $count = 0;
610 $errors = 0;
611 foreach ( $namespaces as $ns ) {
612 foreach ( $likes as $like ) {
613 $cont = [];
614 do {
615 $res = $db->select(
616 $table,
617 $selectFields,
618 array_merge( [ "$nsField = $ns", $like ], $cont ),
619 __METHOD__,
620 [ 'ORDER BY' => array_merge( [ $titleField ], $pkFields ), 'LIMIT' => $batchSize ]
621 );
622 $cont = [];
623 foreach ( $res as $row ) {
624 $cont = '';
625 foreach ( $contFields as $field ) {
626 $v = $db->addQuotes( $row->$field );
627 if ( $cont === '' ) {
628 $cont = "$field > $v";
629 } else {
630 $cont = "$field > $v OR $field = $v AND ($cont)";
631 }
632 }
633 $cont = [ $cont ];
634
635 if ( $op === self::MOVE ) {
636 $ns = is_int( $nsField ) ? $nsField : (int)$row->$nsField;
637 $ret = $this->doMove( $db, $ns, $row->$titleField );
638 } else {
639 $ret = $this->doUpdate( $db, $op, $table, $nsField, $titleField, $row );
640 }
641 if ( $ret === true ) {
642 $count++;
643 } elseif ( $ret === false ) {
644 $errors++;
645 }
646 }
647
648 if ( $this->run ) {
649 $r = $cont ? json_encode( $row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) : '<end>';
650 $this->output( "... $table: $count renames, $errors errors at $r\n" );
651 $lbFactory->waitForReplication(
652 [ 'timeout' => 30, 'ifWritesSince' => $lastReplicationWait ]
653 );
654 $lastReplicationWait = microtime( true );
655 }
656 } while ( $cont );
657 }
658 }
659
660 $this->output( "Done processing table `$table`.\n" );
661 }
662
667 private function processUsers( IDatabase $db ) {
668 $userlistFile = $this->getOption( 'userlist' );
669 if ( $userlistFile === null ) {
670 $this->output( "Not generating user list, --userlist was not specified.\n" );
671 return;
672 }
673
674 $fh = fopen( $userlistFile, 'wb' );
675 if ( !$fh ) {
676 $this->error( "Could not open user list file $userlistFile" );
677 return;
678 }
679
680 $this->output( "Generating user list...\n" );
681 $count = 0;
682 $batchSize = $this->getBatchSize();
683 foreach ( $this->getLikeBatches( $db, 'user_name' ) as $like ) {
684 $cont = [];
685 while ( true ) {
686 $names = $db->selectFieldValues(
687 'user',
688 'user_name',
689 array_merge( [ $like ], $cont ),
690 __METHOD__,
691 [ 'ORDER BY' => 'user_name', 'LIMIT' => $batchSize ]
692 );
693 if ( !$names ) {
694 break;
695 }
696
697 $last = end( $names );
698 $cont = [ 'user_name > ' . $db->addQuotes( $last ) ];
699 foreach ( $names as $name ) {
700 $char = mb_substr( $name, 0, 1 );
701 if ( !array_key_exists( $char, $this->charmap ) ) {
702 $this->error(
703 "Query returned $name, but user name does not begin with a character in the charmap."
704 );
705 continue;
706 }
707 $newName = $this->charmap[$char] . mb_substr( $name, 1 );
708 fprintf( $fh, "%s\t%s\n", $name, $newName );
709 $count++;
710 }
711 $this->output( "... at $last, $count names so far\n" );
712 }
713 }
714
715 if ( !fclose( $fh ) ) {
716 $this->error( "fclose on $userlistFile failed" );
717 }
718 $this->output( "User list output to $userlistFile, $count users need renaming.\n" );
719 }
720}
721
722$maintClass = UppercaseTitlesForUnicodeTransition::class;
723require_once RUN_MAINTENANCE_IF_MAIN;
getDB()
const NS_USER
Definition Defines.php:66
const NS_FILE
Definition Defines.php:70
const NS_MAIN
Definition Defines.php:64
const NS_USER_TALK
Definition Defines.php:67
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
float $lastReplicationWait
UNIX timestamp.
getBatchSize()
Returns batch size.
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.
setBatchSize( $s=0)
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Represents a title within MediaWiki.
Definition Title.php:48
getNamespace()
Get the namespace index, i.e.
Definition Title.php:1078
exists( $flags=0)
Check if page exists.
Definition Title.php:3572
canExist()
Can this title represent a page in the wiki's database?
Definition Title.php:1236
getDBkey()
Get the main part with underscores.
Definition Title.php:1069
getText()
Get the text form (spaces not underscores) of the main part.
Definition Title.php:1051
getPrefixedText()
Get the prefixed title with spaces.
Definition Title.php:1921
Maintenance script to rename titles affected by changes to Unicode (or otherwise to Language::ucfirst...
processTable(IDatabase $db, $op, $table, $nsField, $titleField, $pkFields)
Rename entries in other tables.
doMove(IDatabase $db, $ns, $title)
Use MovePage to move a title.
shouldDelete(IDatabase $db, Title $oldTitle, Title $newTitle)
Determine whether the old title should be deleted.
isUserPage(IDatabase $db, $ns, $title)
Check if a ns+title is a registered user's page.
mungeTitle(IDatabase $db, Title $oldTitle, Title &$newTitle)
Munge a target title, if necessary.
getLikeBatches(IDatabase $db, $field, $batchSize=100)
Get batched LIKE conditions from the charmap.
doUpdate(IDatabase $db, $op, $table, $nsField, $titleField, $row)
Directly update a database row.
getNamespaces()
Get the list of namespaces to operate on.
processUsers(IDatabase $db)
List users needing renaming.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:69
static newFromName( $name, $validate='valid')
Definition User.php:607
isRegistered()
Get whether the user is registered.
Definition User.php:2966
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
Definition User.php:810
const MAINTENANCE_SCRIPT_USER
Username used for various maintenance scripts.
Definition User.php:122
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38
makeList(array $a, $mode=self::LIST_COMMA)
Makes an encoded list of strings from an array.
buildLike( $param,... $params)
LIKE statement wrapper.
selectRow( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
Wrapper to IDatabase::select() that only fetches one row (via LIMIT)
select( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
anyString()
Returns a token for buildLike() that denotes a '' to be used in a LIKE query.
update( $table, $set, $conds, $fname=__METHOD__, $options=[])
Update all rows in a table that match a given condition.
addQuotes( $s)
Escape and quote a raw value string for use in a SQL query.
selectField( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a single field from a single result row.
selectFieldValues( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
A SELECT wrapper which returns a list of single field values from result rows.
const DB_REPLICA
Definition defines.php:25
const DB_PRIMARY
Definition defines.php:27