MediaWiki
REL1_24
|
00001 <?php 00025 require_once __DIR__ . '/Maintenance.php'; 00026 00032 class FixUserRegistration extends Maintenance { 00033 public function __construct() { 00034 parent::__construct(); 00035 $this->mDescription = "Fix the user_registration field"; 00036 } 00037 00038 public function execute() { 00039 $dbr = wfGetDB( DB_SLAVE ); 00040 $dbw = wfGetDB( DB_MASTER ); 00041 00042 // Get user IDs which need fixing 00043 $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', __METHOD__ ); 00044 foreach ( $res as $row ) { 00045 $id = $row->user_id; 00046 // Get first edit time 00047 $timestamp = $dbr->selectField( 00048 'revision', 00049 'MIN(rev_timestamp)', 00050 array( 'rev_user' => $id ), 00051 __METHOD__ 00052 ); 00053 // Update 00054 if ( !empty( $timestamp ) ) { 00055 $dbw->update( 00056 'user', 00057 array( 'user_registration' => $timestamp ), 00058 array( 'user_id' => $id ), 00059 __METHOD__ 00060 ); 00061 $this->output( "$id $timestamp\n" ); 00062 } else { 00063 $this->output( "$id NULL\n" ); 00064 } 00065 } 00066 $this->output( "\n" ); 00067 } 00068 } 00069 00070 $maintClass = "FixUserRegistration"; 00071 require_once RUN_MAINTENANCE_IF_MAIN;