MediaWiki  REL1_22
checkUsernames.php
Go to the documentation of this file.
00001 <?php
00024 require_once __DIR__ . '/Maintenance.php';
00025 
00034 class CheckUsernames extends Maintenance {
00035 
00036     public function __construct() {
00037         parent::__construct();
00038         $this->mDescription = "Verify that database usernames are actually valid";
00039         $this->setBatchSize( 1000 );
00040     }
00041 
00042     function execute() {
00043         $dbr = wfGetDB( DB_SLAVE );
00044 
00045         $maxUserId = 0;
00046         do {
00047             $res = $dbr->select( 'user',
00048                 array( 'user_id', 'user_name' ),
00049                 array( 'user_id > ' . $maxUserId ),
00050                 __METHOD__,
00051                 array(
00052                     'ORDER BY' => 'user_id',
00053                     'LIMIT' => $this->mBatchSize,
00054                 )
00055             );
00056 
00057             foreach ( $res as $row ) {
00058                 if ( ! User::isValidUserName( $row->user_name ) ) {
00059                     $this->error( sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name ) );
00060                     wfDebugLog( 'checkUsernames', $row->user_name );
00061                 }
00062             }
00063             $maxUserId = $row->user_id;
00064         } while ( $res->numRows() );
00065     }
00066 }
00067 
00068 $maintClass = "CheckUsernames";
00069 require_once RUN_MAINTENANCE_IF_MAIN;