Merge maintenance-work branch:
[lhc/web/wiklou.git] / maintenance / checkUsernames.php
1 <?php
2 /**
3 * This script verifies that database usernames are actually valid.
4 * An existing usernames can become invalid if User::isValidUserName()
5 * is altered or if we change the $wgMaxNameChars
6 * @file
7 * @ingroup Maintenance
8 */
9
10
11 require_once( "Maintenance.php" );
12
13 class CheckUsernames extends Maintenance {
14
15 public function __construct() {
16 parent::__construct();
17 $this->mDescription = "Verify that database usernames are actually valid";
18 }
19
20 function execute() {
21 $dbr = wfGetDB( DB_SLAVE );
22
23 $res = $dbr->select( 'user',
24 array( 'user_id', 'user_name' ),
25 null,
26 __METHOD__
27 );
28
29 while ( $row = $dbr->fetchObject( $res ) ) {
30 if ( ! User::isValidUserName( $row->user_name ) ) {
31 $this->error( sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name ) );
32 wfDebugLog( 'checkUsernames', $out );
33 }
34 }
35 }
36 }
37
38 $maintClass = "CheckUsernames";
39 require_once( "doMaintenance.php" );