X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FuserOptions.inc;h=5d773d14263df3b5a2f86518d748ad9538a27b34;hb=28c96dbb83a27f23d1295a9cd621f9ba7a1462ff;hp=f4ffbd04af1cac64ca8b06ecfa924672e0d24338;hpb=ff9f2fa33719753ff0c708f9b4a84c57593b9e58;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index f4ffbd04af..5d773d1426 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -22,8 +22,8 @@ */ // Options we will use -$options = array( 'list', 'nowarn', 'quiet', 'usage', 'dry' ); -$optionsWithArgs = array( 'old', 'new' ); +$options = [ 'list', 'nowarn', 'quiet', 'usage', 'dry' ]; +$optionsWithArgs = [ 'old', 'new' ]; require_once __DIR__ . '/commandLine.inc'; @@ -82,7 +82,6 @@ class UserOptions { * @return bool */ private function initializeOpts( $opts, $args ) { - $this->mQuick = isset( $opts['nowarn'] ); $this->mQuiet = isset( $opts['quiet'] ); $this->mDry = isset( $opts['dry'] ); @@ -137,24 +136,22 @@ class UserOptions { * List options usage */ private function USAGER() { - $ret = array(); + $ret = []; $defaultOptions = User::getDefaultOptions(); - // We list user by user_id from one of the slave database - $dbr = wfGetDB( DB_SLAVE ); + // We list user by user_id from one of the replica DBs + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'user', - array( 'user_id' ), - array(), + [ 'user_id' ], + [], __METHOD__ ); foreach ( $result as $id ) { - $user = User::newFromId( $id->user_id ); // Get the options and update stats if ( $this->mAnOption ) { - if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) { print "Invalid user option. Use --list to see valid choices\n"; exit; @@ -194,23 +191,21 @@ class UserOptions { private function CHANGER() { $this->warn(); - // We list user by user_id from one of the slave database - $dbr = wfGetDB( DB_SLAVE ); + // We list user by user_id from one of the replica DBs + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'user', - array( 'user_id' ), - array(), + [ 'user_id' ], + [], __METHOD__ ); foreach ( $result as $id ) { - $user = User::newFromId( $id->user_id ); $curValue = $user->getOption( $this->mAnOption ); $username = $user->getName(); if ( $curValue == $this->mOldValue ) { - if ( !$this->mQuiet ) { print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " . "to '{$this->mNewValue}'): "; @@ -238,7 +233,7 @@ class UserOptions { */ public static function getDefaultOptionsNames() { $def = User::getDefaultOptions(); - $ret = array(); + $ret = []; foreach ( $def as $optname => $defaultValue ) { array_push( $ret, $optname ); } @@ -279,7 +274,6 @@ USAGE; * @return bool */ public function warn() { - if ( $this->mQuick ) { return true; }