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