Starter for a re-jig of hit counting (in a per-day table).
[lhc/web/wiklou.git] / maintenance / checkUsernames.php
index 479f327..77565b9 100644 (file)
@@ -1,4 +1,12 @@
 <?php
+/**
+ * This script verifies that database usernames are actually valid.
+ * An existing usernames can become invalid if User::isValidUserName()
+ * is altered or if we change the $wgMaxNameChars
+ * @file
+ * @ingroup Maintenance
+ */
+
 error_reporting(E_ALL ^ E_NOTICE);
 require_once 'commandLine.inc';
 
@@ -7,25 +15,23 @@ class checkUsernames {
 
        function checkUsernames() {
                $this->stderr = fopen( 'php://stderr', 'wt' );
-               $this->log = fopen( '/home/wikipedia/logs/checkUsernames.log', 'at' );
        }
        function main() {
-               global $wgDBname;
                $fname = 'checkUsernames::main';
-               
-               $dbr =& wfGetDB( DB_SLAVE );
-               
+
+               $dbr = wfGetDB( DB_SLAVE );
+
                $res = $dbr->select( 'user',
                        array( 'user_id', 'user_name' ),
                        null,
                        $fname
                );
 
-               fwrite( $this->stderr, "Checking $wgDBname\n" );
                while ( $row = $dbr->fetchObject( $res ) ) {
                        if ( ! User::isValidUserName( $row->user_name ) ) {
-                               $out = sprintf( "%s: %6d: %s\n", $wgDBname, $row->user_id, $row->user_name );
-                               fwrite( $this->log, $out );
+                               $out = sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name );
+                               fwrite( $this->stderr, $out );
+                               wfDebugLog( 'checkUsernames', $out );
                        }
                }
        }
@@ -33,3 +39,4 @@ class checkUsernames {
 
 $cun = new checkUsernames();
 $cun->main();
+