Drop rc_cur_time from recentchanges
[lhc/web/wiklou.git] / maintenance / fixUserRegistration.php
index 15c00b3..878593c 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @file
  * @ingroup Maintenance
  */
 
-require_once( "Maintenance.php" );
+require_once __DIR__ . '/Maintenance.php';
 
+/**
+ * Maintenance script that fixes the user_registration field.
+ *
+ * @ingroup Maintenance
+ */
 class FixUserRegistration extends Maintenance {
        public function __construct() {
                parent::__construct();
@@ -35,13 +41,23 @@ class FixUserRegistration extends Maintenance {
 
                // Get user IDs which need fixing
                $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', __METHOD__ );
-               while ( $row = $dbr->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        $id = $row->user_id;
                        // Get first edit time
-                       $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), __METHOD__ );
+                       $timestamp = $dbr->selectField(
+                               'revision',
+                               'MIN(rev_timestamp)',
+                               array( 'rev_user' => $id ),
+                               __METHOD__
+                       );
                        // Update
                        if ( !empty( $timestamp ) ) {
-                               $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), __METHOD__ );
+                               $dbw->update(
+                                       'user',
+                                       array( 'user_registration' => $timestamp ),
+                                       array( 'user_id' => $id ),
+                                       __METHOD__
+                               );
                                $this->output( "$id $timestamp\n" );
                        } else {
                                $this->output( "$id NULL\n" );
@@ -52,4 +68,4 @@ class FixUserRegistration extends Maintenance {
 }
 
 $maintClass = "FixUserRegistration";
-require_once( DO_MAINTENANCE );
+require_once RUN_MAINTENANCE_IF_MAIN;