MediaWiki
REL1_19
|
00001 <?php 00024 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00025 00026 class FixUserRegistration extends Maintenance { 00027 public function __construct() { 00028 parent::__construct(); 00029 $this->mDescription = "Fix the user_registration field"; 00030 } 00031 00032 public function execute() { 00033 $dbr = wfGetDB( DB_SLAVE ); 00034 $dbw = wfGetDB( DB_MASTER ); 00035 00036 // Get user IDs which need fixing 00037 $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', __METHOD__ ); 00038 foreach ( $res as $row ) { 00039 $id = $row->user_id; 00040 // Get first edit time 00041 $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), __METHOD__ ); 00042 // Update 00043 if ( !empty( $timestamp ) ) { 00044 $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), __METHOD__ ); 00045 $this->output( "$id $timestamp\n" ); 00046 } else { 00047 $this->output( "$id NULL\n" ); 00048 } 00049 } 00050 $this->output( "\n" ); 00051 } 00052 } 00053 00054 $maintClass = "FixUserRegistration"; 00055 require_once( RUN_MAINTENANCE_IF_MAIN );