]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/checkUsernames.php
MediaWiki 1.14.0-scripts
[autoinstalls/mediawiki.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 error_reporting(E_ALL ^ E_NOTICE);
11 require_once 'commandLine.inc';
12
13 class checkUsernames {
14         var $stderr, $log;
15
16         function checkUsernames() {
17                 $this->stderr = fopen( 'php://stderr', 'wt' );
18         }
19         function main() {
20                 $fname = 'checkUsernames::main';
21
22                 $dbr = wfGetDB( DB_SLAVE );
23
24                 $res = $dbr->select( 'user',
25                         array( 'user_id', 'user_name' ),
26                         null,
27                         $fname
28                 );
29
30                 while ( $row = $dbr->fetchObject( $res ) ) {
31                         if ( ! User::isValidUserName( $row->user_name ) ) {
32                                 $out = sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name );
33                                 fwrite( $this->stderr, $out );
34                                 wfDebugLog( 'checkUsernames', $out );
35                         }
36                 }
37         }
38 }
39
40 $cun = new checkUsernames();
41 $cun->main();
42