Fix for r47482: put the RELEASE-NOTES entry in the "bug fixes" section and not the...
[mediawiki.git] / maintenance / fixUserRegistration.php
blobeb5b7f7df317cafc083deabb8946220c6096a7e7
1 <?php
2 /**
3 * Fix the user_registration field.
4 * In particular, for values which are NULL, set them to the date of the first edit
6 * @file
7 * @ingroup Maintenance
8 */
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 ) ) {
21 $id = $row->user_id;
22 // Get first edit time
23 $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), $fname );
24 // Update
25 if ( !empty( $timestamp ) ) {
26 $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), $fname );
27 print "$id $timestamp\n";
28 } else {
29 print "$id NULL\n";
32 print "\n";