3 * Fix the user_registration field.
4 * In particular, for values which are NULL, set them to the date of the first edit
10 require_once( 'commandLine.inc' );
12 $fname = 'fixUserRegistration.php';
14 $dbr = wfGetDB( DB_SLAVE
);
15 $dbw = wfGetDB( DB_MASTER
);
17 // Get user IDs which need fixing
18 $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', $fname );
20 while ( $row = $dbr->fetchObject( $res ) ) {
22 // Get first edit time
23 $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), $fname );
25 if ( !empty( $timestamp ) ) {
26 $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), $fname );
27 print "$id $timestamp\n";