X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FconvertUserOptions.php;h=14557f42f9a0b73387307a89affd27fa10adf3e3;hb=5f1a4a3dfc049a742184d5690d211fb0321c9b9d;hp=1542a8c37e200c4a6c2e3913ab31c00fc0602641;hpb=723a59730757cf31629027a567785145c5c131fa;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertUserOptions.php b/maintenance/convertUserOptions.php index 1542a8c37e..14557f42f9 100644 --- a/maintenance/convertUserOptions.php +++ b/maintenance/convertUserOptions.php @@ -34,14 +34,14 @@ class ConvertUserOptions extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Convert user options from old to new system"; + $this->addDescription( 'Convert user options from old to new system' ); $this->setBatchSize( 50 ); } public function execute() { $this->output( "...batch conversion of user_options: " ); $id = 0; - $dbw = wfGetDB( DB_MASTER ); + $dbw = $this->getDB( DB_MASTER ); if ( !$dbw->fieldExists( 'user', 'user_options', __METHOD__ ) ) { $this->output( "nothing to migrate. " ); @@ -50,16 +50,16 @@ class ConvertUserOptions extends Maintenance { } while ( $id !== null ) { $res = $dbw->select( 'user', - array( 'user_id', 'user_options' ), - array( + [ 'user_id', 'user_options' ], + [ 'user_id > ' . $dbw->addQuotes( $id ), "user_options != " . $dbw->addQuotes( '' ), - ), + ], __METHOD__, - array( + [ 'ORDER BY' => 'user_id', 'LIMIT' => $this->mBatchSize, - ) + ] ); $id = $this->convertOptionBatch( $res, $dbw ); @@ -81,9 +81,9 @@ class ConvertUserOptions extends Maintenance { $id = null; foreach ( $res as $row ) { $this->mConversionCount++; - $insertRows = array(); + $insertRows = []; foreach ( explode( "\n", $row->user_options ) as $s ) { - $m = array(); + $m = []; if ( !preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) { continue; } @@ -92,22 +92,22 @@ class ConvertUserOptions extends Maintenance { // here (as in User) to avoid adding many unnecessary rows. $defaultOption = User::getDefaultOption( $m[1] ); if ( is_null( $defaultOption ) || $m[2] != $defaultOption ) { - $insertRows[] = array( + $insertRows[] = [ 'up_user' => $row->user_id, 'up_property' => $m[1], 'up_value' => $m[2], - ); + ]; } } if ( count( $insertRows ) ) { - $dbw->insert( 'user_properties', $insertRows, __METHOD__, array( 'IGNORE' ) ); + $dbw->insert( 'user_properties', $insertRows, __METHOD__, [ 'IGNORE' ] ); } $dbw->update( 'user', - array( 'user_options' => '' ), - array( 'user_id' => $row->user_id ), + [ 'user_options' => '' ], + [ 'user_id' => $row->user_id ], __METHOD__ ); $id = $row->user_id;