MediaWiki REL1_31
checkUsernames.php
Go to the documentation of this file.
1<?php
24require_once __DIR__ . '/Maintenance.php';
25
35
36 public function __construct() {
37 parent::__construct();
38 $this->addDescription( 'Verify that database usernames are actually valid' );
39 $this->setBatchSize( 1000 );
40 }
41
42 function execute() {
43 $dbr = $this->getDB( DB_REPLICA );
44
45 $maxUserId = 0;
46 do {
47 $res = $dbr->select( 'user',
48 [ 'user_id', 'user_name' ],
49 [ 'user_id > ' . $maxUserId ],
50 __METHOD__,
51 [
52 'ORDER BY' => 'user_id',
53 'LIMIT' => $this->getBatchSize(),
54 ]
55 );
56
57 foreach ( $res as $row ) {
58 if ( !User::isValidUserName( $row->user_name ) ) {
59 $this->output( sprintf( "Found: %6d: '%s'\n", $row->user_id, $row->user_name ) );
60 wfDebugLog( 'checkUsernames', $row->user_name );
61 }
62 }
63 $maxUserId = $row->user_id;
64 } while ( $res->numRows() );
65 }
66}
67
68$maintClass = CheckUsernames::class;
69require_once RUN_MAINTENANCE_IF_MAIN;
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
$maintClass
Maintenance script to check that database usernames are actually valid.
__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=[], $wiki=false)
Returns a database to be used by current maintenance script.
getBatchSize()
Returns batch size.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
static isValidUserName( $name)
Is the input a valid username?
Definition User.php:969
$res
Definition database.txt:21
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
require_once RUN_MAINTENANCE_IF_MAIN
const DB_REPLICA
Definition defines.php:25