X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FfixUserRegistration.php;h=878593c71cbe1b3d6b48dba582072d715598bbde;hb=2b441eba406f2c4988da80d264738d45930bf041;hp=15c00b3d495dca3761eacb90a83dd921adacdf26;hpb=a1c51e18af85a9ac464c5b555921e58ec422cd11;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/fixUserRegistration.php b/maintenance/fixUserRegistration.php index 15c00b3d49..878593c71c 100644 --- a/maintenance/fixUserRegistration.php +++ b/maintenance/fixUserRegistration.php @@ -18,11 +18,17 @@ * 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;