X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FconvertUserOptions.php;h=14557f42f9a0b73387307a89affd27fa10adf3e3;hb=52cc0c249e95ba757b4a02d2f5633d0e1a71f8f2;hp=11768c8a5618a54f7d9d5ea4838977fd9a875388;hpb=13e788862bc4349d732286970d57cd8375a7d774;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertUserOptions.php b/maintenance/convertUserOptions.php index 11768c8a56..14557f42f9 100644 --- a/maintenance/convertUserOptions.php +++ b/maintenance/convertUserOptions.php @@ -34,7 +34,7 @@ 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 ); } @@ -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;